Stub updates for RawFirBuilder
First step for KT-52615
This commit is contained in:
+13
-3
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.metadata.ProtoBuf.Modality
|
||||
import org.jetbrains.kotlin.metadata.deserialization.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinConstructorStubImpl
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinFunctionStubImpl
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinPlaceHolderStubImpl
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinPropertyStubImpl
|
||||
import org.jetbrains.kotlin.resolve.DataClassResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
|
||||
@@ -170,6 +170,9 @@ private class FunctionClsStubBuilder(
|
||||
override fun doCreateCallableStub(parent: StubElement<out PsiElement>): StubElement<out PsiElement> {
|
||||
val callableName = c.nameResolver.getName(functionProto.name)
|
||||
|
||||
// Note that arguments passed to stubs here and elsewhere are based on what stabs would be generated based on decompiled code
|
||||
// As functions are never decompiled to fun f() = 1 form, hasBlockBody is always true
|
||||
// This info is anyway irrelevant for the purposes these stubs are used
|
||||
return KotlinFunctionStubImpl(
|
||||
parent,
|
||||
callableName.ref(),
|
||||
@@ -237,6 +240,8 @@ private class PropertyClsStubBuilder(
|
||||
override fun doCreateCallableStub(parent: StubElement<out PsiElement>): StubElement<out PsiElement> {
|
||||
val callableName = c.nameResolver.getName(propertyProto.name)
|
||||
|
||||
// Note that arguments passed to stubs here and elsewhere are based on what stabs would be generated based on decompiled code
|
||||
// This info is anyway irrelevant for the purposes these stubs are used
|
||||
return KotlinPropertyStubImpl(
|
||||
parent,
|
||||
callableName.ref(),
|
||||
@@ -287,9 +292,14 @@ private class ConstructorClsStubBuilder(
|
||||
}
|
||||
|
||||
override fun doCreateCallableStub(parent: StubElement<out PsiElement>): StubElement<out PsiElement> {
|
||||
val name = (protoContainer as ProtoContainer.Class).classId.shortClassName.ref()
|
||||
// Note that arguments passed to stubs here and elsewhere are based on what stabs would be generated based on decompiled code
|
||||
// As decompiled code for secondary constructor would be just constructor(args) { /* compiled code */ } every secondary constructor
|
||||
// delegated call is not to this (as there is no this keyword) and it has body (while primary does not have one)
|
||||
// This info is anyway irrelevant for the purposes these stubs are used
|
||||
return if (Flags.IS_SECONDARY.get(constructorProto.flags))
|
||||
KotlinPlaceHolderStubImpl(parent, KtStubElementTypes.SECONDARY_CONSTRUCTOR)
|
||||
KotlinConstructorStubImpl(parent, KtStubElementTypes.SECONDARY_CONSTRUCTOR, name, hasBody = true, isDelegatedCallToThis = false)
|
||||
else
|
||||
KotlinPlaceHolderStubImpl(parent, KtStubElementTypes.PRIMARY_CONSTRUCTOR)
|
||||
KotlinConstructorStubImpl(parent, KtStubElementTypes.PRIMARY_CONSTRUCTOR, name, hasBody = false, isDelegatedCallToThis = false)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.analysis.decompiler.stub
|
||||
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.psi.KtContextReceiver
|
||||
import org.jetbrains.kotlin.psi.KtContextReceiverList
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinContextReceiverStubImpl
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinPlaceHolderStubImpl
|
||||
|
||||
internal class ContextReceiversListStubBuilder(c: ClsStubBuilderContext) {
|
||||
@@ -21,7 +21,7 @@ internal class ContextReceiversListStubBuilder(c: ClsStubBuilderContext) {
|
||||
KotlinPlaceHolderStubImpl<KtContextReceiverList>(parent, KtStubElementTypes.CONTEXT_RECEIVER_LIST)
|
||||
for (contextReceiverType in contextReceiverTypes) {
|
||||
val contextReceiverStub =
|
||||
KotlinPlaceHolderStubImpl<KtContextReceiver>(contextReceiverListStub, KtStubElementTypes.CONTEXT_RECEIVER)
|
||||
KotlinContextReceiverStubImpl(contextReceiverListStub, KtStubElementTypes.CONTEXT_RECEIVER, label = null)
|
||||
typeStubBuilder.createTypeReferenceStub(contextReceiverStub, contextReceiverType)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user