SSR: fix matching super calls
authorBas Leijdekkers <basleijdekkers@gmail.com>
Wed, 19 Oct 2016 17:09:03 +0000 (19:09 +0200)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Wed, 19 Oct 2016 17:26:37 +0000 (19:26 +0200)
java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java
platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java

index d1fa39927abf661f40076bf3af9d8fe4bc53920d..c648e2256c83f52ffb1136ce0385ba9f39819803 100644 (file)
@@ -1342,7 +1342,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
 
   @Override
   public void visitSuperExpression(final PsiSuperExpression super1) {
 
   @Override
   public void visitSuperExpression(final PsiSuperExpression super1) {
-    myMatchingVisitor.setResult(true);
+    myMatchingVisitor.setResult(myMatchingVisitor.getElement() instanceof PsiSuperExpression);
   }
 
   @Override
   }
 
   @Override
index 316aadc640d313c6e2e3ae91d76191affac8c2d3..205354813a19d65e7a180c87843f1d16788c37fd 100644 (file)
@@ -3488,4 +3488,16 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
     assertEquals("find diamond new expressions", 3, findMatchesCount(source, "new A<>()"));
     assertEquals("find parameterized new expressions", 2, findMatchesCount(source, "new A<Integer, String>()"));
   }
     assertEquals("find diamond new expressions", 3, findMatchesCount(source, "new A<>()"));
     assertEquals("find parameterized new expressions", 2, findMatchesCount(source, "new A<Integer, String>()"));
   }
+
+
+
+  public void testFindSuperCall() {
+    String source = "class A {" +
+                    "  public String toString() {" +
+                    "    System.out.println();" +
+                    "    return super.toString();" +
+                    "  }" +
+                    "}";
+    assertEquals("find super call", 1, findMatchesCount(source, "super.$m$()"));
+  }
 }
 }