JVM: remove StubClassBuilder and its usage
After legacy light classes were removed, the only remaining usage was in KotlinLightClassBuilderFactory where we ran JVM backend in the LIGHT_CLASSES mode, and that was only used from diagnostic tests to report JVM backend diagnostics. We don't actually need to build stubs here, so we can just use ASM's class writer, which means that StubClassBuilder and all its dependencies can be removed.
This commit is contained in:
committed by
Space Team
parent
e5ad035039
commit
2f056fe155
+1
-41
@@ -5,19 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.asJava.builder;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.compiled.ClsClassImpl;
|
||||
import com.intellij.psi.impl.compiled.ClsEnumConstantImpl;
|
||||
import com.intellij.psi.impl.compiled.ClsFieldImpl;
|
||||
import com.intellij.psi.impl.java.stubs.*;
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClsWrapperStubPsiFactory extends StubPsiFactory {
|
||||
public static final Key<LightElementOrigin> ORIGIN = Key.create("ORIGIN");
|
||||
public static final ClsWrapperStubPsiFactory INSTANCE = new ClsWrapperStubPsiFactory();
|
||||
|
||||
private final StubPsiFactory delegate = new ClsStubPsiFactory();
|
||||
@@ -26,16 +20,7 @@ public class ClsWrapperStubPsiFactory extends StubPsiFactory {
|
||||
|
||||
@Override
|
||||
public PsiClass createClass(@NotNull PsiClassStub stub) {
|
||||
PsiElement origin = getOriginalElement(stub);
|
||||
return new ClsClassImpl(stub) {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getNavigationElement() {
|
||||
if (origin != null) return origin;
|
||||
|
||||
return super.getNavigationElement();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiClass getSourceMirrorClass() {
|
||||
@@ -44,12 +29,6 @@ public class ClsWrapperStubPsiFactory extends StubPsiFactory {
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getOriginalElement(@NotNull StubElement stub) {
|
||||
LightElementOrigin origin = ((StubBase) stub).getUserData(ORIGIN);
|
||||
return origin != null ? origin.getOriginalElement() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiAnnotation createAnnotation(PsiAnnotationStub stub) {
|
||||
return delegate.createAnnotation(stub);
|
||||
@@ -67,26 +46,7 @@ public class ClsWrapperStubPsiFactory extends StubPsiFactory {
|
||||
|
||||
@Override
|
||||
public PsiField createField(PsiFieldStub stub) {
|
||||
PsiElement origin = getOriginalElement(stub);
|
||||
if (origin == null) return delegate.createField(stub);
|
||||
if (stub.isEnumConstant()) {
|
||||
return new ClsEnumConstantImpl(stub) {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getNavigationElement() {
|
||||
return origin;
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
return new ClsFieldImpl(stub) {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getNavigationElement() {
|
||||
return origin;
|
||||
}
|
||||
};
|
||||
}
|
||||
return delegate.createField(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-21
@@ -10,23 +10,9 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
|
||||
|
||||
interface LightElementOrigin {
|
||||
val originalElement: PsiElement?
|
||||
val originKind: JvmDeclarationOriginKind?
|
||||
|
||||
object None : LightElementOrigin {
|
||||
override val originalElement: PsiElement?
|
||||
get() = null
|
||||
override val originKind: JvmDeclarationOriginKind?
|
||||
get() = null
|
||||
|
||||
override fun toString() = "NONE"
|
||||
}
|
||||
}
|
||||
|
||||
interface LightMemberOrigin : LightElementOrigin {
|
||||
override val originalElement: KtDeclaration?
|
||||
override val originKind: JvmDeclarationOriginKind
|
||||
interface LightMemberOrigin {
|
||||
val originalElement: KtDeclaration?
|
||||
val originKind: JvmDeclarationOriginKind
|
||||
val parametersForJvmOverloads: List<KtParameter?>? get() = null
|
||||
val auxiliaryOriginalElement: KtDeclaration? get() = null
|
||||
|
||||
@@ -59,7 +45,3 @@ data class LightMemberOriginForDeclaration(
|
||||
return LightMemberOriginForDeclaration(originalElement.copy() as KtDeclaration, originKind, parametersForJvmOverloads)
|
||||
}
|
||||
}
|
||||
|
||||
data class DefaultLightElementOrigin(override val originalElement: PsiElement?) : LightElementOrigin {
|
||||
override val originKind: JvmDeclarationOriginKind? get() = null
|
||||
}
|
||||
Reference in New Issue
Block a user