PR review
This commit is contained in:
@ -9,7 +9,7 @@ import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import net.sourceforge.pmd.lang.AntlrTokenManager;
|
||||
import net.sourceforge.pmd.lang.antlr.AntlrTokenManager;
|
||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
||||
|
||||
/**
|
||||
@ -23,7 +23,6 @@ public abstract class AntlrTokenizer implements Tokenizer {
|
||||
public void tokenize(final SourceCode sourceCode, final Tokens tokenEntries) {
|
||||
|
||||
AntlrTokenManager tokenManager = getLexerForSource(sourceCode);
|
||||
tokenManager.resetListeners();
|
||||
|
||||
try {
|
||||
Token token = (Token) tokenManager.getNextToken();
|
||||
|
@ -2,13 +2,15 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang;
|
||||
package net.sourceforge.pmd.lang.antlr;
|
||||
|
||||
import org.antlr.v4.runtime.BaseErrorListener;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.Recognizer;
|
||||
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
|
||||
/**
|
||||
* Generic token manager implementation for all Antlr lexers.
|
||||
*/
|
||||
@ -25,6 +27,7 @@ public class AntlrTokenManager implements TokenManager {
|
||||
public AntlrTokenManager(final Lexer lexer, final String fileName) {
|
||||
this.lexer = lexer;
|
||||
this.fileName = fileName;
|
||||
resetListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +44,7 @@ public class AntlrTokenManager implements TokenManager {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void resetListeners() {
|
||||
private void resetListeners() {
|
||||
lexer.removeErrorListeners();
|
||||
lexer.addErrorListener(new ErrorHandler());
|
||||
}
|
@ -6,7 +6,7 @@ package net.sourceforge.pmd.cpd;
|
||||
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
|
||||
import net.sourceforge.pmd.lang.AntlrTokenManager;
|
||||
import net.sourceforge.pmd.lang.antlr.AntlrTokenManager;
|
||||
import net.sourceforge.pmd.lang.swift.antlr4.SwiftLexer;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user