Make Antlr token manager throw TokenMgrError directly

This commit is contained in:
Clément Fournier
2020-03-22 00:45:46 +01:00
parent 62a9d5b655
commit 16f30c9ece
8 changed files with 40 additions and 49 deletions

View File

@ -9,7 +9,7 @@ import java.util.Properties;
import org.antlr.v4.runtime.CharStream;
import net.sourceforge.pmd.cpd.internal.AntlrTokenizer;
import net.sourceforge.pmd.cpd.token.AntlrToken;
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrToken;
import net.sourceforge.pmd.cpd.token.AntlrTokenFilter;
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrTokenManager;
import net.sourceforge.pmd.lang.cs.antlr4.CSharpLexer;
@ -79,7 +79,7 @@ public class CsTokenizer extends AntlrTokenizer {
private void skipUsingDirectives(final AntlrToken currentToken, final Iterable<AntlrToken> remainingTokens) {
if (ignoreUsings) {
final int type = currentToken.getType();
final int type = currentToken.getKind();
if (type == CSharpLexer.USING && isUsingDirective(remainingTokens)) {
discardingUsings = true;
} else if (type == CSharpLexer.SEMICOLON && discardingUsings) {
@ -92,7 +92,7 @@ public class CsTokenizer extends AntlrTokenizer {
private boolean isUsingDirective(final Iterable<AntlrToken> remainingTokens) {
UsingState usingState = UsingState.KEYWORD;
for (final AntlrToken token : remainingTokens) {
final int type = token.getType();
final int type = token.getKind();
if (usingState == UsingState.KEYWORD) {
// The previous token was a using keyword.
switch (type) {
@ -148,7 +148,7 @@ public class CsTokenizer extends AntlrTokenizer {
}
private void skipNewLines(final AntlrToken currentToken) {
discardingNL = currentToken.getType() == CSharpLexer.NL;
discardingNL = currentToken.getKind() == CSharpLexer.NL;
}
@Override