mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
find usages: explicit this/super means that super/this were not called implicitly
This commit is contained in:
+6
-2
@@ -110,7 +110,7 @@ class ConstructorReferencesSearchHelper {
|
||||
if (!DumbService.getInstance(project).runReadActionInSmartMode(
|
||||
() -> processSuperOrThis(containingClass, constructor, constructorCanBeCalledImplicitly[0], searchScope, project,
|
||||
isStrictSignatureSearch,
|
||||
PsiKeyword.THIS, processor))) {
|
||||
PsiKeyword.THIS, PsiKeyword.SUPER, processor))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class ConstructorReferencesSearchHelper {
|
||||
final PsiElement navigationElement = inheritor.getNavigationElement();
|
||||
if (navigationElement instanceof PsiClass) {
|
||||
return processSuperOrThis((PsiClass)navigationElement, constructor, constructorCanBeCalledImplicitly[0], searchScope, project,
|
||||
isStrictSignatureSearch, PsiKeyword.SUPER, processor);
|
||||
isStrictSignatureSearch, PsiKeyword.SUPER, PsiKeyword.THIS, processor);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -186,6 +186,7 @@ class ConstructorReferencesSearchHelper {
|
||||
@NotNull Project project,
|
||||
final boolean isStrictSignatureSearch,
|
||||
@NotNull String superOrThisKeyword,
|
||||
@NotNull String thisOrSuperKeyword,
|
||||
@NotNull Processor<PsiReference> processor) {
|
||||
PsiMethod[] constructors = inheritor.getConstructors();
|
||||
if (constructors.length == 0 && constructorCanBeCalledImplicitly) {
|
||||
@@ -216,6 +217,9 @@ class ConstructorReferencesSearchHelper {
|
||||
//as long as we've encountered super/this keyword, no implicit ctr calls are possible here
|
||||
continue;
|
||||
}
|
||||
else if (refExpr.textMatches(thisOrSuperKeyword)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,17 @@ class FindFixtureBasedTest : LightCodeInsightFixtureTestCase() {
|
||||
val references = MethodReferencesSearch.search(constructors[0]).findAll()
|
||||
assertSize(1, references)
|
||||
}
|
||||
|
||||
fun testDefaultConstructorNotInvoked() {
|
||||
val aClass = myFixture.addClass("public class A {\n" +
|
||||
" public A() {}\n" +
|
||||
" public A(String s){}\n" +
|
||||
" public A(int i) {this(null);}\n" +
|
||||
"}")
|
||||
myFixture.addClass("class B extends A {public B(){this(\"\");} public B(String s) {super(s);} }")
|
||||
|
||||
val constructors = aClass.constructors
|
||||
assertSize(3, constructors)
|
||||
assertNull(MethodReferencesSearch.search(constructors[0]).findFirst())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user