Make Antlr token implementation respect its contract
This commit is contained in:
@ -16,6 +16,7 @@ public class AntlrToken implements GenericToken<AntlrToken> {
|
||||
|
||||
private final Token token;
|
||||
private final AntlrToken previousComment;
|
||||
AntlrToken next;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -30,8 +31,7 @@ public class AntlrToken implements GenericToken<AntlrToken> {
|
||||
|
||||
@Override
|
||||
public AntlrToken getNext() {
|
||||
// Antlr implementation does not require this
|
||||
return null;
|
||||
return next;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +45,9 @@ public class AntlrTokenManager implements TokenManager<AntlrToken> {
|
||||
private AntlrToken getNextTokenFromAnyChannel() {
|
||||
final AntlrToken previousComment = previousToken != null && previousToken.isHidden() ? previousToken : null;
|
||||
final AntlrToken currentToken = new AntlrToken(lexer.nextToken(), previousComment);
|
||||
if (previousToken != null) {
|
||||
previousToken.next = currentToken;
|
||||
}
|
||||
previousToken = currentToken;
|
||||
|
||||
return currentToken;
|
||||
|
Reference in New Issue
Block a user