From 0ce6234ba76a3bd998e753bf17c3db2196a7dd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sun, 21 Jul 2019 23:43:35 +0200 Subject: [PATCH] Simplify GTToken --- pmd-java/etc/grammar/Java.jjt | 12 ++++-------- .../pmd/lang/java/ast/JavaTokenUtils.java | 6 +++++- 2 files changed, 9 insertions(+), 9 deletions(-) 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;