From 0859285b8b319c825f54ff548773bcc076e93077 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 3 Aug 2013 21:38:16 +0200 Subject: [PATCH] pmd: fixed #1107 PMD 5.0.4 couldn't parse call of parent outer java class method from inner class --- pmd/etc/changelog.txt | 1 + pmd/etc/grammar/Java.jjt | 1 + .../pmd/ast/ParserCornersTest.java | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 0a37cf768c..f10b0ae8bb 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -4,6 +4,7 @@ Fixed bug 991: AvoidSynchronizedAtMethodLevel for static methods Fixed bug 1084: NPE at UselessStringValueOfRule.java:36 Fixed bug 1092: Wrong Attribute "excludemarker" in Ant Task Documentation Fixed bug 1104: IdempotentOperation false positive +Fixed bug 1107: PMD 5.0.4 couldn't parse call of parent outer java class method from inner class Fixed bug 1111: False positive: Useless parentheses Fixed bug 1114: CPD - Tokenizer not initialized with requested properties Fixed bug 1118: ClassCastException in pmd.lang.ecmascript.ast.ASTElementGet diff --git a/pmd/etc/grammar/Java.jjt b/pmd/etc/grammar/Java.jjt index a63a8f76f2..d895771b67 100644 --- a/pmd/etc/grammar/Java.jjt +++ b/pmd/etc/grammar/Java.jjt @@ -1719,6 +1719,7 @@ void PrimaryPrefix() : void PrimarySuffix() : {Token t;} { LOOKAHEAD(2) "." "this" +| LOOKAHEAD(2) "." "super" | LOOKAHEAD(2) "." AllocationExpression() | LOOKAHEAD(3) MemberSelector() | "[" Expression() "]" {jjtThis.setIsArrayDereference();} diff --git a/pmd/src/test/java/net/sourceforge/pmd/ast/ParserCornersTest.java b/pmd/src/test/java/net/sourceforge/pmd/ast/ParserCornersTest.java index 9c64eb7b36..51bc89d4fe 100644 --- a/pmd/src/test/java/net/sourceforge/pmd/ast/ParserCornersTest.java +++ b/pmd/src/test/java/net/sourceforge/pmd/ast/ParserCornersTest.java @@ -16,6 +16,30 @@ import org.junit.Test; public class ParserCornersTest extends ParserTst { + /** + * #1107 PMD 5.0.4 couldn't parse call of parent outer java class method from inner class + * @throws Exception any error + */ + @Test + public void testInnerOuterClass() throws Exception { + parseJava17("/**\n" + + " * @author azagorulko\n" + + " *\n" + + " */\n" + + "public class TestInnerClassCallsOuterParent {\n" + + "\n" + + " public void test() {\n" + + " new Runnable() {\n" + + " @Override\n" + + " public void run() {\n" + + " TestInnerClassCallsOuterParent.super.toString();\n" + + " }\n" + + " };\n" + + " }\n" + + "}\n" + ); + } + @Test public final void testGetFirstASTNameImageNull() throws Throwable { parseJava14(ABSTRACT_METHOD_LEVEL_CLASS_DECL);