SSR: no duplicate results when searching for symbols

This commit is contained in:
Bas Leijdekkers
2016-05-01 12:19:44 +02:00
parent 4238d90f9f
commit 3e7a0aaef8
2 changed files with 11 additions and 3 deletions
@@ -13,9 +13,8 @@ public class SymbolHandler extends MatchingHandler {
this.handler = handler;
}
@Override
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
// there is no need to do filtering since this is delegate of Substituion handler
return handler.handle(matchedNode,context);
return handler.canMatch(patternNode, matchedNode) && handler.handle(matchedNode, context);
}
}
@@ -1398,6 +1398,15 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
final String pattern2 = "'_:[write && regex( i )]";
assertEquals("Find writes of symbol", 3, findMatchesCount(in, pattern2));
final String source = "class A {" +
" static A a() {};" +
" void m() {" +
" A a = A.a();" +
" }" +
"}";
final String pattern3 = "A";
assertEquals("No duplicate results", 4, findMatchesCount(source, pattern3));
}
public void testSearchGenerics() {