Get rid of BinarySource interface, use SourceElement instead
This commit is contained in:
+7
-2
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.BinarySource
|
||||
|
||||
class JvmPackagePartSource(val className: JvmClassName, val facadeClassName: JvmClassName?) : BinarySource {
|
||||
class JvmPackagePartSource(val className: JvmClassName, val facadeClassName: JvmClassName?) : SourceElement {
|
||||
constructor(kotlinClass: KotlinJvmBinaryClass) : this(
|
||||
JvmClassName.byClassId(kotlinClass.classId),
|
||||
kotlinClass.classHeader.multifileClassName?.let {
|
||||
@@ -32,4 +33,8 @@ class JvmPackagePartSource(val className: JvmClassName, val facadeClassName: Jvm
|
||||
val simpleName: Name get() = Name.identifier(className.internalName.substringAfterLast('/'))
|
||||
|
||||
val classId: ClassId get() = ClassId(className.packageFqName, simpleName)
|
||||
|
||||
override fun toString() = "${javaClass.simpleName}: $className"
|
||||
|
||||
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
|
||||
}
|
||||
|
||||
+2
-3
@@ -18,9 +18,8 @@ package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.BinarySource
|
||||
|
||||
class KotlinJvmBinarySourceElement(val binaryClass: KotlinJvmBinaryClass) : SourceElement, BinarySource {
|
||||
override fun toString() = javaClass.name + ": " + binaryClass.toString()
|
||||
class KotlinJvmBinarySourceElement(val binaryClass: KotlinJvmBinaryClass) : SourceElement {
|
||||
override fun toString() = "${javaClass.simpleName}: $binaryClass"
|
||||
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
|
||||
}
|
||||
|
||||
+4
-4
@@ -17,22 +17,22 @@
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.BinarySource
|
||||
|
||||
sealed class ProtoContainer(
|
||||
val nameResolver: NameResolver,
|
||||
val typeTable: TypeTable,
|
||||
val source: BinarySource?
|
||||
val source: SourceElement?
|
||||
) {
|
||||
class Class(
|
||||
val classProto: ProtoBuf.Class,
|
||||
nameResolver: NameResolver,
|
||||
typeTable: TypeTable,
|
||||
source: BinarySource?,
|
||||
source: SourceElement?,
|
||||
val outerClassKind: ClassKind?
|
||||
) : ProtoContainer(nameResolver, typeTable, source) {
|
||||
val classId: ClassId = nameResolver.getClassId(classProto.fqName)
|
||||
@@ -47,7 +47,7 @@ sealed class ProtoContainer(
|
||||
val fqName: FqName,
|
||||
nameResolver: NameResolver,
|
||||
typeTable: TypeTable,
|
||||
source: BinarySource?
|
||||
source: SourceElement?
|
||||
) : ProtoContainer(nameResolver, typeTable, source) {
|
||||
override fun debugFqName(): FqName = fqName
|
||||
}
|
||||
|
||||
+2
-3
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.BinarySource
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
class DeserializationComponents(
|
||||
@@ -49,7 +48,7 @@ class DeserializationComponents(
|
||||
descriptor: PackageFragmentDescriptor,
|
||||
nameResolver: NameResolver,
|
||||
typeTable: TypeTable,
|
||||
containerSource: BinarySource?
|
||||
containerSource: SourceElement?
|
||||
): DeserializationContext =
|
||||
DeserializationContext(this, nameResolver, descriptor, typeTable, containerSource,
|
||||
parentTypeDeserializer = null, typeParameters = listOf())
|
||||
@@ -61,7 +60,7 @@ class DeserializationContext(
|
||||
val nameResolver: NameResolver,
|
||||
val containingDeclaration: DeclarationDescriptor,
|
||||
val typeTable: TypeTable,
|
||||
val containerSource: BinarySource?,
|
||||
val containerSource: SourceElement?,
|
||||
parentTypeDeserializer: TypeDeserializer?,
|
||||
typeParameters: List<ProtoBuf.TypeParameter>
|
||||
) {
|
||||
|
||||
+4
-6
@@ -36,11 +36,9 @@ interface DeserializedCallableMemberDescriptor : CallableMemberDescriptor {
|
||||
val typeTable: TypeTable
|
||||
|
||||
// Information about the origin of this callable's container (class or package part on JVM) or null if there's no such information.
|
||||
val containerSource: BinarySource?
|
||||
val containerSource: SourceElement?
|
||||
}
|
||||
|
||||
interface BinarySource
|
||||
|
||||
class DeserializedSimpleFunctionDescriptor(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
original: SimpleFunctionDescriptor?,
|
||||
@@ -50,7 +48,7 @@ class DeserializedSimpleFunctionDescriptor(
|
||||
override val proto: ProtoBuf.Function,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable,
|
||||
override val containerSource: BinarySource?
|
||||
override val containerSource: SourceElement?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
SimpleFunctionDescriptorImpl(containingDeclaration, original, annotations, name, kind, SourceElement.NO_SOURCE) {
|
||||
|
||||
@@ -82,7 +80,7 @@ class DeserializedPropertyDescriptor(
|
||||
override val proto: ProtoBuf.Property,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable,
|
||||
override val containerSource: BinarySource?
|
||||
override val containerSource: SourceElement?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
PropertyDescriptorImpl(containingDeclaration, original, annotations,
|
||||
modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE, isLateInit, isConst) {
|
||||
@@ -110,7 +108,7 @@ class DeserializedConstructorDescriptor(
|
||||
override val proto: ProtoBuf.Constructor,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable,
|
||||
override val containerSource: BinarySource?
|
||||
override val containerSource: SourceElement?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
ConstructorDescriptorImpl(containingDeclaration, original, annotations, isPrimary, kind, SourceElement.NO_SOURCE) {
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class DeserializedClassDescriptor(
|
||||
private val companionObjectDescriptor = c.storageManager.createNullableLazyValue { computeCompanionObjectDescriptor() }
|
||||
|
||||
internal val thisAsProtoContainer = ProtoContainer.Class(
|
||||
classProto, c.nameResolver, c.typeTable, sourceElement as? BinarySource, (containingDeclaration as? ClassDescriptor)?.kind
|
||||
classProto, c.nameResolver, c.typeTable, sourceElement, (containingDeclaration as? ClassDescriptor)?.kind
|
||||
)
|
||||
|
||||
private val annotations =
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.serialization.deserialization.descriptors
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -36,7 +37,7 @@ open class DeserializedPackageMemberScope(
|
||||
packageDescriptor: PackageFragmentDescriptor,
|
||||
proto: ProtoBuf.Package,
|
||||
nameResolver: NameResolver,
|
||||
containerSource: BinarySource?,
|
||||
containerSource: SourceElement?,
|
||||
components: DeserializationComponents,
|
||||
classNames: () -> Collection<Name>
|
||||
) : DeserializedMemberScope(
|
||||
|
||||
+4
-4
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.isNumberedFunctionClassFqName
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.FlagsToModifiers.*
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -37,14 +38,13 @@ import org.jetbrains.kotlin.psi.stubs.impl.KotlinPlaceHolderStubImpl
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.BinarySource
|
||||
|
||||
fun createClassStub(
|
||||
parent: StubElement<out PsiElement>,
|
||||
classProto: ProtoBuf.Class,
|
||||
nameResolver: NameResolver,
|
||||
classId: ClassId,
|
||||
source: BinarySource?,
|
||||
source: SourceElement?,
|
||||
context: ClsStubBuilderContext
|
||||
) {
|
||||
ClassClsStubBuilder(parent, classProto, nameResolver, classId, source, context).build()
|
||||
@@ -55,7 +55,7 @@ private class ClassClsStubBuilder(
|
||||
private val classProto: ProtoBuf.Class,
|
||||
private val nameResolver: NameResolver,
|
||||
private val classId: ClassId,
|
||||
private val source: BinarySource?,
|
||||
private val source: SourceElement?,
|
||||
private val outerContext: ClsStubBuilderContext
|
||||
) {
|
||||
private val classKind = Flags.CLASS_KIND[classProto.flags]
|
||||
@@ -253,7 +253,7 @@ private class ClassClsStubBuilder(
|
||||
return
|
||||
}
|
||||
val (nameResolver, classProto) = classDataWithSource.classData
|
||||
createClassStub(classBody, classProto, nameResolver, nestedClassId, classDataWithSource.sourceElement as? BinarySource, c)
|
||||
createClassStub(classBody, classProto, nameResolver, nestedClassId, classDataWithSource.sourceElement, c)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+2
-2
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import com.intellij.util.io.StringRef
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinFileStubForIde
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -40,13 +41,12 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.BinarySource
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
|
||||
fun createTopLevelClassStub(
|
||||
classId: ClassId,
|
||||
classProto: ProtoBuf.Class,
|
||||
source: BinarySource?,
|
||||
source: SourceElement?,
|
||||
context: ClsStubBuilderContext
|
||||
): KotlinFileStubImpl {
|
||||
val fileStub = createFileStub(classId.packageFqName)
|
||||
|
||||
Reference in New Issue
Block a user