diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java
index 7d2c1360d..71aab5ec2 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java
@@ -19,7 +19,6 @@
package com.puppycrawl.tools.checkstyle;
import antlr.RecognitionException;
-import antlr.TokenStream;
import antlr.TokenStreamException;
import antlr.TokenStreamRecognitionException;
import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
@@ -58,55 +57,6 @@ import org.apache.commons.logging.LogFactory;
public final class TreeWalker
extends AbstractFileSetCheck
{
- /**
- * Overrides ANTLR error reporting so we completely control
- * checkstyle's output during parsing. This is important because
- * we try parsing with several grammers (with/without support for
- * assert). We must not write any error messages when
- * parsing fails because with the next grammar it might succeed
- * and the user will be confused.
- */
- private static final class SilentJavaRecognizer
- extends GeneratedJavaRecognizer
- {
- /**
- * Creates a new SilentJavaRecognizer instance.
- *
- * @param aLexer the tokenstream the recognizer operates on.
- */
- public SilentJavaRecognizer(TokenStream aLexer)
- {
- super(aLexer);
- }
-
- /**
- * Parser error-reporting function, does nothing.
- * @param aRex the exception to be reported
- */
- @Override
- public void reportError(RecognitionException aRex)
- {
- }
-
- /**
- * Parser error-reporting function, does nothing.
- * @param aMsg the error message
- */
- @Override
- public void reportError(String aMsg)
- {
- }
-
- /**
- * Parser warning-reporting function, does nothing.
- * @param aMsg the error message
- */
- @Override
- public void reportWarning(String aMsg)
- {
- }
- }
-
/** default distance between tab stops */
private static final int DEFAULT_TAB_WIDTH = 8;
@@ -521,52 +471,16 @@ public final class TreeWalker
*/
public static DetailAST parse(FileContents aContents)
throws RecognitionException, TokenStreamException
- {
- DetailAST rootAST = null;
-
- try {
- rootAST = parse(aContents, true, true, true);
- }
- catch (final RecognitionException exception) {
- try {
- rootAST = parse(aContents, true, true, false);
- }
- catch (final RecognitionException exception2) {
- rootAST = parse(aContents, false, false, false);
- }
- }
- return rootAST;
- }
-
- /**
- * Static helper method to parses a Java source file with a given
- * lexer class and parser class.
- * @param aContents contains the contents of the file
- * @param aSilentlyConsumeErrors flag to output errors to stdout or not
- * @param aTreatAssertAsKeyword flag to treat 'assert' as a keyowrd
- * @param aTreatEnumAsKeyword flag to treat 'enum' as a keyowrd
- * @throws TokenStreamException if lexing failed
- * @throws RecognitionException if parsing failed
- * @return the root of the AST
- */
- private static DetailAST parse(
- FileContents aContents,
- boolean aSilentlyConsumeErrors,
- boolean aTreatAssertAsKeyword,
- boolean aTreatEnumAsKeyword)
- throws RecognitionException, TokenStreamException
{
final Reader sar = new StringArrayReader(aContents.getLines());
final GeneratedJavaLexer lexer = new GeneratedJavaLexer(sar);
lexer.setFilename(aContents.getFilename());
lexer.setCommentListener(aContents);
- lexer.setTreatAssertAsKeyword(aTreatAssertAsKeyword);
- lexer.setTreatEnumAsKeyword(aTreatEnumAsKeyword);
+ lexer.setTreatAssertAsKeyword(true);
+ lexer.setTreatEnumAsKeyword(true);
final GeneratedJavaRecognizer parser =
- aSilentlyConsumeErrors
- ? new SilentJavaRecognizer(lexer)
- : new GeneratedJavaRecognizer(lexer);
+ new GeneratedJavaRecognizer(lexer);
parser.setFilename(aContents.getFilename());
parser.setASTNodeClass(DetailAST.class.getName());
parser.compilationUnit();
diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputAssertIdentifier.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputAssertIdentifier.java
deleted file mode 100644
index 845789426..000000000
--- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputAssertIdentifier.java
+++ /dev/null
@@ -1,24 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-// Test case file for checkstyle.
-// Created: 2001
-////////////////////////////////////////////////////////////////////////////////
-package com.puppycrawl.tools.checkstyle;
-
-import java.util.Properties;
-
-/**
- * Test case for assert handling fallback.
- * This file uses "assert" is as an identifier, so the default grammar
- * fails and the JDK 1.3 grammar has to be used.
- * @author Lars Kühne
- **/
-class InputAssertIdentifier
-{
- /** test method **/
- void assert()
- {
- int assert = 1;
- int a = assert;
- final Properties p = null;
- }
-}
diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/grammars/Post13KeywordsAsIdentifiersOK.java b/src/testinputs/com/puppycrawl/tools/checkstyle/grammars/Post13KeywordsAsIdentifiersOK.java
deleted file mode 100644
index ae2a96748..000000000
--- a/src/testinputs/com/puppycrawl/tools/checkstyle/grammars/Post13KeywordsAsIdentifiersOK.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.puppycrawl.tools.checkstyle.grammars;
-
-/**
- * @author Michael Studman
- * @see
- */
-public class Post13KeywordsAsIdentifiersOK
-{
- public int assert = 0;
- public int enum = 0;
-}
diff --git a/src/tests/com/puppycrawl/tools/checkstyle/grammars/AllTests.java b/src/tests/com/puppycrawl/tools/checkstyle/grammars/AllTests.java
index 2b87b5900..9eff4a3ea 100644
--- a/src/tests/com/puppycrawl/tools/checkstyle/grammars/AllTests.java
+++ b/src/tests/com/puppycrawl/tools/checkstyle/grammars/AllTests.java
@@ -15,7 +15,6 @@ public class AllTests {
new TestSuite("Test for com.puppycrawl.tools.checkstyle.grammars");
//$JUnit-BEGIN$
suite.addTest(new TestSuite(GeneratedJava14LexerTest.class));
- suite.addTest(new TestSuite(Post13KeywordsAsIdentifiersOKTest.class));
suite.addTest(new TestSuite(HexFloatsTest.class));
suite.addTest(new TestSuite(EmbeddedNullCharTest.class));
suite.addTest(new TestSuite(VarargTest.class));
diff --git a/src/tests/com/puppycrawl/tools/checkstyle/grammars/Post13KeywordsAsIdentifiersOKTest.java b/src/tests/com/puppycrawl/tools/checkstyle/grammars/Post13KeywordsAsIdentifiersOKTest.java
deleted file mode 100644
index c14f3d828..000000000
--- a/src/tests/com/puppycrawl/tools/checkstyle/grammars/Post13KeywordsAsIdentifiersOKTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.puppycrawl.tools.checkstyle.grammars;
-
-import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
-import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
-import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
-
-import java.io.IOException;
-
-/**
- * @author Michael Studman
- */
-public class Post13KeywordsAsIdentifiersOKTest
- extends BaseCheckTestCase
-{
- public void testUnexpectedChar() throws IOException, Exception
- {
- final DefaultConfiguration checkConfig =
- createCheckConfig(MemberNameCheck.class);
- verify(checkConfig, getPath("grammars/Post13KeywordsAsIdentifiersOK.java"), new String[0]);
- }
-}