Better information for unexpected char, RFE 666188
This commit is contained in:
parent
d622cf7e42
commit
44e3d33fc2
|
|
@ -1,9 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Checkstyle Release Notes</title>
|
||||
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
|
||||
</head>
|
||||
|
|
@ -90,6 +91,9 @@ checkstyle-user</a>).</li>
|
|||
<li class="body">Added filter that suppresses audit events according to source file
|
||||
comments, contributed by Mike McMahon (module SuppressionCommentFilter,
|
||||
requests 732196 and 931327).</li>
|
||||
|
||||
<li class="body">Better information for unexpected char (request 666188).
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import java.util.Set;
|
|||
|
||||
import antlr.RecognitionException;
|
||||
import antlr.TokenStreamException;
|
||||
import antlr.TokenStreamRecognitionException;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
|
||||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
|
||||
|
|
@ -244,12 +246,37 @@ public final class TreeWalker
|
|||
.debug("RecognitionException occured.", re);
|
||||
getMessageCollector().add(
|
||||
new LocalizedMessage(
|
||||
0,
|
||||
re.getLine(),
|
||||
re.getColumn(),
|
||||
Defn.CHECKSTYLE_BUNDLE,
|
||||
"general.exception",
|
||||
new String[] {re.getMessage()},
|
||||
this.getClass()));
|
||||
}
|
||||
catch (TokenStreamRecognitionException tre) {
|
||||
Utils.getExceptionLogger()
|
||||
.debug("TokenStreamRecognitionException occured.", tre);
|
||||
final RecognitionException re = tre.recog;
|
||||
if (re != null) {
|
||||
getMessageCollector().add(
|
||||
new LocalizedMessage(
|
||||
re.getLine(),
|
||||
re.getColumn(),
|
||||
Defn.CHECKSTYLE_BUNDLE,
|
||||
"general.exception",
|
||||
new String[] {re.getMessage()},
|
||||
this.getClass()));
|
||||
}
|
||||
else {
|
||||
getMessageCollector().add(
|
||||
new LocalizedMessage(
|
||||
0,
|
||||
Defn.CHECKSTYLE_BUNDLE,
|
||||
"general.exception",
|
||||
new String[] {re.getMessage()},
|
||||
this.getClass()));
|
||||
}
|
||||
}
|
||||
catch (TokenStreamException te) {
|
||||
Utils.getExceptionLogger()
|
||||
.debug("TokenStreamException occured.", te);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.puppycrawl.tools.checkstyle.grammars;
|
||||
|
||||
/**
|
||||
* Input for grammar test.
|
||||
*/
|
||||
public class InputGrammar
|
||||
{
|
||||
int é = 1; // illegal, unless UTF-8
|
||||
}
|
||||
|
|
@ -32,7 +32,8 @@ public class AllTests {
|
|||
suite.addTest(com.puppycrawl.tools.checkstyle.api.AllTests.suite());
|
||||
suite.addTest(com.puppycrawl.tools.checkstyle.checks.AllTests.suite());
|
||||
suite.addTest(com.puppycrawl.tools.checkstyle.filters.AllTests.suite());
|
||||
|
||||
suite.addTest(
|
||||
com.puppycrawl.tools.checkstyle.grammars.AllTests.suite());
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.puppycrawl.tools.checkstyle.grammars;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Describe class AllTests.
|
||||
* @author Rick Giles
|
||||
* @version Jun 21, 2004
|
||||
*/
|
||||
public class AllTests {
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite =
|
||||
new TestSuite("Test for com.puppycrawl.tools.checkstyle.grammars");
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTest(new TestSuite(GeneratedJava14LexerTest.class));
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.puppycrawl.tools.checkstyle.grammars;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
|
||||
|
||||
/**
|
||||
* Tests GeneratedJava14Lexer.
|
||||
* @author Rick Giles
|
||||
*/
|
||||
public class GeneratedJava14LexerTest
|
||||
extends BaseCheckTestCase
|
||||
{
|
||||
public void testUnexpectedChar() throws IOException, Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(MemberNameCheck.class);
|
||||
final String[] expected = {
|
||||
"8:10: Got an exception - unexpected char: 0xA9",
|
||||
};
|
||||
verify(checkConfig, getPath("grammars/InputGrammar.java"), expected);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue