[core] Deprecate AntlrToken#getType() in favor of #getKind()

Refs #2371
This commit is contained in:
Andreas Dangel 2020-04-10 18:50:58 +02:00
parent c7941638e8
commit 0710877d05
6 changed files with 19 additions and 10 deletions

View File

@ -123,6 +123,7 @@ implementations, and their corresponding Parser if it exists (in the same packag
* {% jdoc !!core::lang.TokenManager#setFileName(java.lang.String) %}
* {% jdoc !!core::lang.ast.AbstractTokenManager#setFileName(java.lang.String) %}
* {% jdoc !!core::lang.ast.AbstractTokenManager#getFileName(java.lang.String) %}
* {% jdoc !!core::cpd.token.AntlrToken#getType() %} - use `getKind()` instead.
### External Contributions

View File

@ -64,10 +64,18 @@ public class AntlrToken implements GenericToken {
return token.getCharPositionInLine() + token.getStopIndex() - token.getStartIndex();
}
public int getType() {
public int getKind() {
return token.getType();
}
/**
* @deprecated use {@link #getKind()} instead.
*/
@Deprecated
public int getType() {
return getKind();
}
public boolean isHidden() {
return token.getChannel() == Lexer.HIDDEN;
}

View File

@ -25,6 +25,6 @@ public class AntlrTokenFilter extends BaseTokenFilter<AntlrToken> {
@Override
protected boolean shouldStopProcessing(final AntlrToken currentToken) {
return currentToken.getType() == EOF;
return currentToken.getKind() == EOF;
}
}

View File

@ -78,7 +78,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) {
@ -91,7 +91,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) {
@ -147,7 +147,7 @@ public class CsTokenizer extends AntlrTokenizer {
}
private void skipNewLines(final AntlrToken currentToken) {
discardingNL = currentToken.getType() == CSharpLexer.NL;
discardingNL = currentToken.getKind() == CSharpLexer.NL;
}
@Override

View File

@ -52,7 +52,7 @@ public class DartTokenizer extends AntlrTokenizer {
}
private void skipLibraryAndImport(final AntlrToken currentToken) {
final int type = currentToken.getType();
final int type = currentToken.getKind();
if (type == Dart2Lexer.LIBRARY || type == Dart2Lexer.IMPORT) {
discardingLibraryAndImport = true;
} else if (discardingLibraryAndImport && (type == Dart2Lexer.SEMICOLON || type == Dart2Lexer.NEWLINE)) {
@ -61,11 +61,11 @@ public class DartTokenizer extends AntlrTokenizer {
}
private void skipNewLines(final AntlrToken currentToken) {
discardingNL = currentToken.getType() == Dart2Lexer.NEWLINE;
discardingNL = currentToken.getKind() == Dart2Lexer.NEWLINE;
}
private void skipSemicolons(final AntlrToken currentToken) {
discardingSemicolon = currentToken.getType() == Dart2Lexer.SEMICOLON;
discardingSemicolon = currentToken.getKind() == Dart2Lexer.SEMICOLON;
}
@Override

View File

@ -50,7 +50,7 @@ public class KotlinTokenizer extends AntlrTokenizer {
}
private void skipPackageAndImport(final AntlrToken currentToken) {
final int type = currentToken.getType();
final int type = currentToken.getKind();
if (type == Kotlin.PACKAGE || type == Kotlin.IMPORT) {
discardingPackageAndImport = true;
} else if (discardingPackageAndImport && (type == Kotlin.SEMICOLON || type == Kotlin.NL)) {
@ -59,7 +59,7 @@ public class KotlinTokenizer extends AntlrTokenizer {
}
private void skipNewLines(final AntlrToken currentToken) {
discardingNL = currentToken.getType() == Kotlin.NL;
discardingNL = currentToken.getKind() == Kotlin.NL;
}
@Override