SSR: match annotated instanceof expression correctly

This commit is contained in:
Bas Leijdekkers
2015-02-11 16:37:08 +01:00
parent 3b144bc3d5
commit 1c0a734b95
2 changed files with 9 additions and 1 deletions
@@ -1453,7 +1453,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
if (myMatchingVisitor.getResult()) {
final PsiTypeElement checkType = instanceOf.getCheckType();
if (checkType != null) {
myMatchingVisitor.setResult(matchType(checkType, instanceOf2.getCheckType()));
myMatchingVisitor.setResult(myMatchingVisitor.match(checkType, instanceOf2.getCheckType()));
}
}
}
@@ -2476,6 +2476,14 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
"@Deprecated\n" +
"package one.two;";
assertEquals("Find annotation on package statement", 1, findMatchesCount(source4, "@'_Annotation", true));
final String source5 ="class A {" +
" boolean a(Object o) {" +
" return o instanceof @HH String;" +
" }" +
"}";
assertEquals("Find annotation on instanceof expression", 1, findMatchesCount(source5, "'_a instanceof @HH String"));
assertEquals("Match annotation correctly on instanceof expression", 0, findMatchesCount(source5, "'_a instanceof @GG String"));
}
public void testBoxingAndUnboxing() {