Fast implementation for KtLightClassForExplicitDeclaration#getContainingClass()
Prevent computing stubs for light classes for nested/inner classes when calling completion from java
This commit is contained in:
+6
@@ -47,6 +47,12 @@ class KtLightClassForAnonymousDeclaration extends KtLightClassForExplicitDeclara
|
|||||||
return JavaPsiFacade.getElementFactory(getClassOrObject().getProject()).createReferenceElementByType(getBaseClassType());
|
return JavaPsiFacade.getElementFactory(getClassOrObject().getProject()).createReferenceElementByType(getBaseClassType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public PsiClass getContainingClass() {
|
||||||
|
return getDelegate().getContainingClass();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String getFirstSupertypeFQName() {
|
private String getFirstSupertypeFQName() {
|
||||||
ClassDescriptor descriptor = getDescriptor();
|
ClassDescriptor descriptor = getDescriptor();
|
||||||
|
|||||||
+7
@@ -230,6 +230,13 @@ public open class KtLightClassForExplicitDeclaration(
|
|||||||
|
|
||||||
override fun getContainingClass(): PsiClass? {
|
override fun getContainingClass(): PsiClass? {
|
||||||
if (classOrObject.parent === classOrObject.containingFile) return null
|
if (classOrObject.parent === classOrObject.containingFile) return null
|
||||||
|
|
||||||
|
val containingClassOrObject = (classOrObject.parent as? KtClassBody)?.parent as? KtClassOrObject
|
||||||
|
if (containingClassOrObject != null) {
|
||||||
|
return create(containingClassOrObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: should return null
|
||||||
return super.getContainingClass()
|
return super.getContainingClass()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -46,4 +46,6 @@ public open class KtLightClassForInterfaceDefaultImpls(
|
|||||||
override fun setName(name: String): PsiElement {
|
override fun setName(name: String): PsiElement {
|
||||||
throw IncorrectOperationException("Impossible to rename DefaultImpls")
|
throw IncorrectOperationException("Impossible to rename DefaultImpls")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getContainingClass() = KtLightClassForExplicitDeclaration.create(classOrObject)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
import mockLib.foo
|
||||||
|
|
||||||
|
public class Testing {
|
||||||
|
public static void test() {
|
||||||
|
Nest<caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: Nested
|
||||||
|
// EXIST: NestedObject
|
||||||
+6
@@ -137,6 +137,12 @@ public class CompiledKotlinInJavaCompletionTestGenerated extends AbstractCompile
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedNoImport.java")
|
||||||
|
public void testNestedNoImport() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/injava/NestedNoImport.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NestedObjectInstance.java")
|
@TestMetadata("NestedObjectInstance.java")
|
||||||
public void testNestedObjectInstance() throws Exception {
|
public void testNestedObjectInstance() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/injava/NestedObjectInstance.java");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/injava/NestedObjectInstance.java");
|
||||||
|
|||||||
+6
@@ -137,6 +137,12 @@ public class KotlinSourceInJavaCompletionTestGenerated extends AbstractKotlinSou
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedNoImport.java")
|
||||||
|
public void testNestedNoImport() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/injava/NestedNoImport.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NestedObjectInstance.java")
|
@TestMetadata("NestedObjectInstance.java")
|
||||||
public void testNestedObjectInstance() throws Exception {
|
public void testNestedObjectInstance() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/injava/NestedObjectInstance.java");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/injava/NestedObjectInstance.java");
|
||||||
|
|||||||
Reference in New Issue
Block a user