[LL] stubBased provider: deserialize fir from stubs build from decompiled text
if the compiled code is opened in the editor, 1. it's decompiled 2. stub is build over decompiled text 3. this stub replaces the stub built from classes. This process leads to missed information in resulted FIR, e.g. half correct classId. On the other side, this FIR is used only for this opened editor.
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
createStubForTypeName(classId, leftReference, { upperBoundType })
|
||||
val rightReference = KotlinPlaceHolderStubImpl<KtTypeReference>(intersectionType, KtStubElementTypes.TYPE_REFERENCE)
|
||||
val userType = KotlinUserTypeStubImpl(rightReference)
|
||||
KotlinNameReferenceExpressionStubImpl(userType, StandardNames.FqNames.any.shortName().ref())
|
||||
KotlinNameReferenceExpressionStubImpl(userType, StandardNames.FqNames.any.shortName().ref(), true)
|
||||
}
|
||||
|
||||
private fun createClassReferenceTypeStub(parent: KotlinStubBaseImpl<*>, type: Type, annotations: List<AnnotationWithTarget>) {
|
||||
|
||||
+2
-2
@@ -141,7 +141,7 @@ fun createStubForTypeName(
|
||||
|
||||
val segments = fqName.pathSegments().asReversed()
|
||||
assert(segments.isNotEmpty())
|
||||
val packageLength = if (substituteWithAny) 1 else typeClassId.packageFqName.pathSegments().size
|
||||
val classesNestedLevel = segments.size - if (substituteWithAny) 1 else typeClassId.packageFqName.pathSegments().size
|
||||
|
||||
fun recCreateStubForType(current: StubElement<out PsiElement>, level: Int): KotlinUserTypeStub {
|
||||
val lastSegment = segments[level]
|
||||
@@ -149,7 +149,7 @@ fun createStubForTypeName(
|
||||
if (level + 1 < segments.size) {
|
||||
recCreateStubForType(userTypeStub, level + 1)
|
||||
}
|
||||
KotlinNameReferenceExpressionStubImpl(userTypeStub, lastSegment.ref(), level < segments.size - packageLength)
|
||||
KotlinNameReferenceExpressionStubImpl(userTypeStub, lastSegment.ref(), level < classesNestedLevel)
|
||||
if (!substituteWithAny) {
|
||||
bindTypeArguments(userTypeStub, level)
|
||||
}
|
||||
|
||||
+8
@@ -290,6 +290,14 @@ internal fun KtUserType.classId(): ClassId {
|
||||
}
|
||||
}
|
||||
collectFragments(this)
|
||||
if (classFragments.isEmpty()) {
|
||||
//stub is re-built from decompiled text and additional information is already missed
|
||||
return ClassId(
|
||||
FqName.fromSegments(packageFragments).parent(),
|
||||
FqName(packageFragments.last()),
|
||||
false
|
||||
)
|
||||
}
|
||||
return ClassId(
|
||||
FqName.fromSegments(packageFragments),
|
||||
FqName.fromSegments(classFragments),
|
||||
|
||||
Reference in New Issue
Block a user