diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index c6bc963dce..ee668ea9c4 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -2999,19 +2999,15 @@ void AssertStatement() : void RUNSIGNEDSHIFT() #void: {} { - ( LOOKAHEAD({ getToken(1).kind == GT && - ((JavaTokenUtils.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) - ">" ">" ">" - ) + LOOKAHEAD({ JavaTokenUtils.getRealKind(getToken(1)) == RUNSIGNEDSHIFT}) + ">" ">" ">" } void RSIGNEDSHIFT() #void: {} { - ( LOOKAHEAD({ getToken(1).kind == GT && - ((JavaTokenUtils.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} ) - ">" ">" - ) + LOOKAHEAD({ JavaTokenUtils.getRealKind(getToken(1)) == RSIGNEDSHIFT}) + ">" ">" } /* Annotation syntax follows. */ diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaTokenUtils.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaTokenUtils.java index c37783fb72..1e67b3093a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaTokenUtils.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaTokenUtils.java @@ -43,7 +43,11 @@ final class JavaTokenUtils { } } - static final class GTToken extends JavaccToken { + static int getRealKind(JavaccToken token) { + return token instanceof GTToken ? ((GTToken) token).realKind : token.kind; + } + + private static final class GTToken extends JavaccToken { final int realKind;