mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: add ability to search in hierarchy on class identifier
This commit is contained in:
+11
-4
@@ -1665,7 +1665,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(PsiClass clazz) {
|
||||
PsiClass clazz2 = (PsiClass)myMatchingVisitor.getElement();
|
||||
final PsiClass clazz2 = (PsiClass)myMatchingVisitor.getElement();
|
||||
if (clazz.hasTypeParameters()) {
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.match(clazz.getTypeParameterList(), clazz2.getTypeParameterList()));
|
||||
if (!myMatchingVisitor.getResult()) return;
|
||||
@@ -1677,7 +1677,8 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
if (!myMatchingVisitor.getResult()) return;
|
||||
}
|
||||
|
||||
final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(clazz.getNameIdentifier());
|
||||
final PsiIdentifier identifier = clazz.getNameIdentifier();
|
||||
final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(identifier);
|
||||
|
||||
if (clazz.getModifierList().getTextLength() > 0) {
|
||||
if (!myMatchingVisitor.match(clazz.getModifierList(), clazz2.getModifierList())) {
|
||||
@@ -1686,13 +1687,19 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
myMatchingVisitor.setResult((myMatchingVisitor.matchText(clazz.getNameIdentifier(), clazz2.getNameIdentifier()) || isTypedVar) &&
|
||||
myMatchingVisitor.setResult((isTypedVar || myMatchingVisitor.matchText(identifier, clazz2.getNameIdentifier())) &&
|
||||
compareClasses(clazz, clazz2));
|
||||
|
||||
if (myMatchingVisitor.getResult() && isTypedVar) {
|
||||
PsiElement id = clazz2.getNameIdentifier();
|
||||
if (id == null) id = clazz2;
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(clazz.getNameIdentifier(), id));
|
||||
final SubstitutionHandler handler = (SubstitutionHandler)myMatchingVisitor.getMatchContext().getPattern().getHandler(identifier);
|
||||
if (handler.isSubtype() || handler.isStrictSubtype()) {
|
||||
myMatchingVisitor.setResult(checkMatchWithinHierarchy(id, handler, identifier));
|
||||
}
|
||||
else {
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(identifier, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -1727,6 +1727,7 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
findMatchesCount(s1, "class '_ extends '_Extends:[!regex( *A )] implements '_Implements:[regex( I )] {}"));
|
||||
assertEquals("Find class within type hierarchy with not, 2", 1,
|
||||
findMatchesCount(s1, "class '_ extends '_Extends:[!regex( *A )]{}"));
|
||||
assertEquals("Search in hierarchy on class identifier", 2, findMatchesCount(s1, "class '_X:*B2 {}"));
|
||||
}
|
||||
|
||||
public void testFindTryWithoutProperFinally() {
|
||||
|
||||
Reference in New Issue
Block a user