mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
SSR: Match multi-catch correctly
This commit is contained in:
@@ -1614,7 +1614,16 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
myMatchingVisitor.setResult(annotations2 != null && myMatchingVisitor.matchInAnyOrder(annotations, annotations2));
|
||||
if (!myMatchingVisitor.getResult()) return;
|
||||
}
|
||||
myMatchingVisitor.setResult(matchType(typeElement, other));
|
||||
final PsiTypeElement[] typeElementChildren = PsiTreeUtil.getChildrenOfType(typeElement, PsiTypeElement.class);
|
||||
if (typeElementChildren != null && typeElementChildren.length > 1) {
|
||||
// multi catch type element
|
||||
final PsiTypeElement[] typeElementChildren2 = PsiTreeUtil.getChildrenOfType(other, PsiTypeElement.class);
|
||||
myMatchingVisitor.setResult(
|
||||
typeElementChildren2 != null && myMatchingVisitor.matchInAnyOrder(typeElementChildren, typeElementChildren2));
|
||||
}
|
||||
else {
|
||||
myMatchingVisitor.setResult(matchType(typeElement, other));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3223,5 +3223,14 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
|
||||
String pattern3 = "try { '_St1*; } finally { '_St2*; }";
|
||||
assertEquals("Find try with finally block", 3, findMatchesCount(source, pattern3));
|
||||
|
||||
String pattern4 = "try { '_St1*; } catch (NullPointerException | IllegalArgumentException '_e) { '_St2*; }";
|
||||
assertEquals("Match multi catch correctly", 0, findMatchesCount(source, pattern4));
|
||||
|
||||
String pattern5 = "try { '_St1*; } catch (UnsupportedOperationException | NullPointerException '_e) { '_St2*; }";
|
||||
assertEquals("Find multi catch", 1, findMatchesCount(source, pattern5));
|
||||
|
||||
String pattern6 = "try { '_St1*; } catch ('_E1 | '_E2 '_e) { '_St2*; }";
|
||||
assertEquals("Find multi catch with variables", 1, findMatchesCount(source, pattern6));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user