mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
find groovy usages of methods overriding the search target
This commit is contained in:
+14
-1
@@ -67,6 +67,7 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -816,7 +817,19 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
|
||||
}
|
||||
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
return getManager().areElementsEquivalent(element, GroovyTargetElementEvaluator.correctSearchTargets(resolve()));
|
||||
PsiElement target = GroovyTargetElementEvaluator.correctSearchTargets(resolve());
|
||||
if (getManager().areElementsEquivalent(element, target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element instanceof PsiMethod && target instanceof PsiMethod) {
|
||||
PsiMethod[] superMethods = ((PsiMethod)target).findSuperMethods(false);
|
||||
if (Arrays.asList(superMethods).contains((PsiMethod)element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -304,7 +304,7 @@ public class PsiUtil {
|
||||
|
||||
public static <Qualifier extends PsiElement> boolean shortenReference(GrQualifiedReference<Qualifier> ref) {
|
||||
final Qualifier qualifier = ref.getQualifier();
|
||||
if (qualifier != null &&
|
||||
if (qualifier != null && !(qualifier instanceof GrSuperReferenceExpression) &&
|
||||
(PsiTreeUtil.getParentOfType(ref, GrDocMemberReference.class) != null ||
|
||||
PsiTreeUtil.getParentOfType(ref, GrDocComment.class) == null) &&
|
||||
PsiTreeUtil.getParentOfType(ref, GrImportStatement.class) == null &&
|
||||
|
||||
@@ -139,6 +139,10 @@ public class FindUsagesTest extends LightGroovyTestCase {
|
||||
doTestImpl("A.groovy", 1);
|
||||
}
|
||||
|
||||
public void testOverridingMethodUsage() throws Throwable {
|
||||
doTestImpl("OverridingMethodUsage.groovy", 2);
|
||||
}
|
||||
|
||||
public void testAnnotatedMemberSearch() throws Throwable {
|
||||
|
||||
final PsiReference ref = myFixture.getReferenceAtCaretPosition("A.groovy");
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Bar {
|
||||
boolean isFo<caret>cused() { }
|
||||
}
|
||||
|
||||
class BarImpl extends Bar {
|
||||
@Override
|
||||
boolean isFocused() { }
|
||||
}
|
||||
|
||||
println new BarImpl().focused
|
||||
println new BarImpl().isFocused()
|
||||
Reference in New Issue
Block a user