From 6ae653e5a120b96cf1b0f074c134567065b09438 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 11 Nov 2015 14:43:19 +0300 Subject: [PATCH] Implement stub building for inner types --- .../kotlin/descriptors/typeParameterUtils.kt | 14 +- .../kotlin/types/TypeCapabilities.kt | 17 ++ .../deserialization/DeserializedType.kt | 31 ++- .../stubBuilder/TypeClsStubBuilder.kt | 15 +- .../decompiler/stubBuilder/clsStubBuilding.kt | 20 +- .../decompiledText/InnerClasses.expected.kt | 17 ++ .../InnerClasses/InnerClasses.kt | 17 ++ .../InnerClasses/directives.txt | 4 + .../stubBuilder/InnerTypes/InnerTypes.kt | 17 ++ .../stubBuilder/InnerTypes/InnerTypes.txt | 217 ++++++++++++++++++ .../NestedClasses/NestedClasses.txt | 10 + .../ClsStubBuilderTestGenerated.java | 6 + ...mpiledTextFromJsMetadataTestGenerated.java | 6 + .../CommonDecompiledTextTestGenerated.java | 6 + 14 files changed, 377 insertions(+), 20 deletions(-) create mode 100644 idea/testData/decompiler/decompiledText/InnerClasses.expected.kt create mode 100644 idea/testData/decompiler/decompiledText/InnerClasses/InnerClasses.kt create mode 100644 idea/testData/decompiler/decompiledText/InnerClasses/directives.txt create mode 100644 idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.kt create mode 100644 idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.txt diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/typeParameterUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/typeParameterUtils.kt index 169419e8421..30c83702075 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/typeParameterUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/typeParameterUtils.kt @@ -16,8 +16,9 @@ package org.jetbrains.kotlin.descriptors -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.TypeProjection +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.error.MissingDependencyErrorClass +import java.util.* fun ClassDescriptor.computeConstructorTypeParameters(): List { val declaredParameters = declaredTypeParameters @@ -55,8 +56,13 @@ class PossiblyInnerType( fun segments(): List = outerType?.segments().orEmpty() + this } -fun KotlinType.buildPossiblyInnerType(): PossiblyInnerType? - = buildPossiblyInnerType(constructor.declarationDescriptor as? ClassDescriptor, 0) +fun KotlinType.buildPossiblyInnerType(): PossiblyInnerType? { + if (constructor.declarationDescriptor is MissingDependencyErrorClass) { + return getCapability()?.possiblyInnerType + } + + return buildPossiblyInnerType(constructor.declarationDescriptor as? ClassDescriptor, 0) +} private fun KotlinType.buildPossiblyInnerType(classDescriptor: ClassDescriptor?, index: Int): PossiblyInnerType? { if (classDescriptor == null) return null diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt index 9cfc1715ca1..a72fbe73c50 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.types +import org.jetbrains.kotlin.descriptors.PossiblyInnerType import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor public interface TypeCapability @@ -28,6 +29,18 @@ public interface TypeCapabilities { fun getCapability(capabilityClass: Class): T? } +class CompositeTypeCapabilities(private val first: TypeCapabilities, private val second: TypeCapabilities) : TypeCapabilities { + override fun getCapability(capabilityClass: Class): T? = + first.getCapability(capabilityClass) ?: second.getCapability(capabilityClass) +} + +class SingletonTypeCapabilities(private val clazz: Class<*>, private val typeCapability: TypeCapability) : TypeCapabilities { + override fun getCapability(capabilityClass: Class): T? { + if (capabilityClass == clazz) return typeCapability as T + return null + } +} + public inline fun KotlinType.getCapability(): T? = getCapability(javaClass()) public interface Specificity : TypeCapability { @@ -88,3 +101,7 @@ public fun sameTypeConstructors(first: KotlinType, second: KotlinType): Boolean interface CustomSubstitutionCapability : TypeCapability { public val substitution: TypeSubstitution } + +interface PossiblyInnerTypeCapability : TypeCapability { + public val possiblyInnerType: PossiblyInnerType? +} diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt index 2e8cdf631a1..4b69ceede5a 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt @@ -16,6 +16,8 @@ package org.jetbrains.kotlin.serialization.deserialization +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.PossiblyInnerType import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.serialization.ProtoBuf @@ -58,7 +60,34 @@ class DeserializedType( override fun getAnnotations(): Annotations = annotations - override fun getCapabilities() = c.components.typeCapabilitiesLoader.loadCapabilities(typeProto) + override fun getCapabilities() = typeCapabilities() + + private val typeCapabilities = c.storageManager.createLazyValue { computeCapabilities() } + + private fun computeCapabilities(): TypeCapabilities { + val capabilities = c.components.typeCapabilitiesLoader.loadCapabilities(typeProto) + + return computePossiblyInnerType()?.let { it: PossiblyInnerType -> + CompositeTypeCapabilities( + SingletonTypeCapabilities( + PossiblyInnerTypeCapability::class.java, + PossiblyInnerTypeCapabilityImpl(it)), + capabilities) + } ?: capabilities + } + + private fun computePossiblyInnerType(): PossiblyInnerType? { + if (!typeProto.hasClassName()) return null + + val outerType = typeProto.outerType(c.typeTable)?.let { DeserializedType(c, it).computePossiblyInnerType() } + + return PossiblyInnerType( + constructor.declarationDescriptor as ClassDescriptor, + typeProto.argumentList.deserialize(), + outerType) + } + + private class PossiblyInnerTypeCapabilityImpl(override val possiblyInnerType: PossiblyInnerType?) : PossiblyInnerTypeCapability fun getPresentableText(): String = typeDeserializer.presentableTextForErrorType(typeProto) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt index 04493b41049..93e614d8809 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.decompiler.stubBuilder import com.google.protobuf.MessageLite import com.intellij.psi.PsiElement import com.intellij.psi.stubs.StubElement +import com.intellij.util.SmartList import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens @@ -35,10 +36,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.ProtoBuf.Type import org.jetbrains.kotlin.serialization.ProtoBuf.Type.Argument.Projection import org.jetbrains.kotlin.serialization.ProtoBuf.TypeParameter.Variance -import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer -import org.jetbrains.kotlin.serialization.deserialization.type -import org.jetbrains.kotlin.serialization.deserialization.upperBounds -import org.jetbrains.kotlin.serialization.deserialization.varargElementType +import org.jetbrains.kotlin.serialization.deserialization.* import org.jetbrains.kotlin.types.DynamicTypeCapabilities import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* @@ -88,9 +86,12 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { return } createTypeAnnotationStubs(parent, annotations) - val typeStub = createStubForTypeName(classId, parent) - val typeArgumentProtoList = type.getArgumentList() - createTypeArgumentListStub(typeStub, typeArgumentProtoList) + val outerTypeChain = sequence(type) { it.outerType(c.typeTable) }.toList() + + createStubForTypeName(classId, parent) { + userTypeStub, index -> + outerTypeChain.getOrNull(index)?.let { createTypeArgumentListStub(userTypeStub, it.argumentList) } + } } private fun createTypeAnnotationStubs(parent: KotlinStubBaseImpl<*>, annotations: List) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt index 0fc37bb3408..29e0138ca95 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt @@ -127,25 +127,29 @@ fun createStubForPackageName(packageDirectiveStub: KotlinPlaceHolderStubImpl): KotlinUserTypeStub { +fun createStubForTypeName( + typeClassId: ClassId, + parent: StubElement, + onUserTypeLevel: (KotlinUserTypeStub, Int) -> Unit = { x, y -> } +): KotlinUserTypeStub { val fqName = if (typeClassId.isLocal()) KotlinBuiltIns.FQ_NAMES.any else typeClassId.asSingleFqName().toUnsafe() - val segments = fqName.pathSegments().toArrayList() + val segments = fqName.pathSegments().asReversed() assert(segments.isNotEmpty()) - val iterator = segments.listIterator(segments.size) - fun recCreateStubForType(current: StubElement): KotlinUserTypeStub { - val lastSegment = iterator.previous() + fun recCreateStubForType(current: StubElement, level: Int): KotlinUserTypeStub { + val lastSegment = segments[level] val userTypeStub = KotlinUserTypeStubImpl(current, isAbsoluteInRootPackage = false) - if (iterator.hasPrevious()) { - recCreateStubForType(userTypeStub) + if (level + 1 < segments.size) { + recCreateStubForType(userTypeStub, level + 1) } KotlinNameReferenceExpressionStubImpl(userTypeStub, lastSegment.ref()) + onUserTypeLevel(userTypeStub, level) return userTypeStub } - return recCreateStubForType(parent) + return recCreateStubForType(parent, level = 0) } enum class FlagsToModifiers { diff --git a/idea/testData/decompiler/decompiledText/InnerClasses.expected.kt b/idea/testData/decompiler/decompiledText/InnerClasses.expected.kt new file mode 100644 index 00000000000..cb4e28848f6 --- /dev/null +++ b/idea/testData/decompiler/decompiledText/InnerClasses.expected.kt @@ -0,0 +1,17 @@ +// IntelliJ API Decompiler stub source generated from a class file +// Implementation of methods is not available + +package test + +public final class InnerClasses public constructor() { + public final fun bar(x: test.InnerClasses.Inner2, y: test.InnerClasses.Inner2): kotlin.Unit { /* compiled code */ } + + public final inner class Inner public constructor() { + public final inner class Inner3 public constructor() { + public final fun foo(x: test.InnerClasses.Inner, y: test.InnerClasses.Inner, z: test.InnerClasses.Inner.Inner3, w: test.InnerClasses.Inner.Inner3<*>): kotlin.Unit { /* compiled code */ } + } + } + + public final inner class Inner2 public constructor() { + } +} diff --git a/idea/testData/decompiler/decompiledText/InnerClasses/InnerClasses.kt b/idea/testData/decompiler/decompiledText/InnerClasses/InnerClasses.kt new file mode 100644 index 00000000000..48f6d52dd84 --- /dev/null +++ b/idea/testData/decompiler/decompiledText/InnerClasses/InnerClasses.kt @@ -0,0 +1,17 @@ +package test + +class InnerClasses { + inner class Inner { + inner class Inner3 { + fun foo( + x: InnerClasses.Inner, + y: Inner, + z: InnerClasses.Inner.Inner3, + w: Inner3<*>) {} + } + } + + inner class Inner2 + + fun bar(x: InnerClasses.Inner2, y: Inner2) {} +} diff --git a/idea/testData/decompiler/decompiledText/InnerClasses/directives.txt b/idea/testData/decompiler/decompiledText/InnerClasses/directives.txt new file mode 100644 index 00000000000..f7d114ce2eb --- /dev/null +++ b/idea/testData/decompiler/decompiledText/InnerClasses/directives.txt @@ -0,0 +1,4 @@ +// TODO Remove this restriction when nested classes will be supported in js backend. +// See KT-1907 Support nested classes in js-backend +// https://youtrack.jetbrains.com/issue/KT-1907 +// TARGET_BACKEND: JVM diff --git a/idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.kt b/idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.kt new file mode 100644 index 00000000000..14a70571610 --- /dev/null +++ b/idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.kt @@ -0,0 +1,17 @@ +package test + +class InnerTypes { + inner class Inner { + inner class Inner3 { + fun foo( + x: InnerTypes.Inner, + y: Inner, + z: InnerTypes.Inner.Inner3, + w: Inner3<*>) {} + } + } + + inner class Inner2 + + fun bar(x: InnerTypes.Inner2, y: Inner2) {} +} diff --git a/idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.txt b/idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.txt new file mode 100644 index 00000000000..5a0d16fcb17 --- /dev/null +++ b/idea/testData/decompiler/stubBuilder/InnerTypes/InnerTypes.txt @@ -0,0 +1,217 @@ +PsiJetFileStubImpl[package=test] + PACKAGE_DIRECTIVE: + REFERENCE_EXPRESSION:[referencedName=test] + IMPORT_LIST: + CLASS:[fqName=test.InnerTypes, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=InnerTypes, superNames=[]] + MODIFIER_LIST:[public final] + TYPE_PARAMETER_LIST: + TYPE_PARAMETER:[fqName=null, isInVariance=false, isOutVariance=false, name=E] + TYPE_PARAMETER:[fqName=null, isInVariance=false, isOutVariance=false, name=F] + PRIMARY_CONSTRUCTOR: + MODIFIER_LIST:[public] + VALUE_PARAMETER_LIST: + CLASS_BODY: + FUN:[fqName=test.InnerTypes.bar, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=bar] + MODIFIER_LIST:[public final] + VALUE_PARAMETER_LIST: + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=x] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=InnerTypes] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=String] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Double] + REFERENCE_EXPRESSION:[referencedName=Inner2] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=y] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=InnerTypes] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=E] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=F] + REFERENCE_EXPRESSION:[referencedName=Inner2] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Unit] + CLASS:[fqName=test.InnerTypes.Inner, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Inner, superNames=[]] + MODIFIER_LIST:[inner public final] + TYPE_PARAMETER_LIST: + TYPE_PARAMETER:[fqName=null, isInVariance=false, isOutVariance=false, name=G] + TYPE_PARAMETER:[fqName=null, isInVariance=false, isOutVariance=false, name=H] + PRIMARY_CONSTRUCTOR: + MODIFIER_LIST:[public] + VALUE_PARAMETER_LIST: + CLASS_BODY: + CLASS:[fqName=test.InnerTypes.Inner.Inner3, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Inner3, superNames=[]] + MODIFIER_LIST:[inner public final] + TYPE_PARAMETER_LIST: + TYPE_PARAMETER:[fqName=null, isInVariance=false, isOutVariance=false, name=I] + PRIMARY_CONSTRUCTOR: + MODIFIER_LIST:[public] + VALUE_PARAMETER_LIST: + CLASS_BODY: + FUN:[fqName=test.InnerTypes.Inner.Inner3.foo, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=foo] + MODIFIER_LIST:[public final] + VALUE_PARAMETER_LIST: + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=x] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=InnerTypes] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=String] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=F] + REFERENCE_EXPRESSION:[referencedName=Inner] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=G] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Int] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=y] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=InnerTypes] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=E] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=F] + REFERENCE_EXPRESSION:[referencedName=Inner] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=E] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Double] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=z] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=InnerTypes] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=String] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=F] + REFERENCE_EXPRESSION:[referencedName=Inner] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=G] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Int] + REFERENCE_EXPRESSION:[referencedName=Inner3] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Double] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=w] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=InnerTypes] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=E] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=F] + REFERENCE_EXPRESSION:[referencedName=Inner] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=G] + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=H] + REFERENCE_EXPRESSION:[referencedName=Inner3] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=STAR] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Unit] + CLASS:[fqName=test.InnerTypes.Inner2, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Inner2, superNames=[]] + MODIFIER_LIST:[inner public final] + PRIMARY_CONSTRUCTOR: + MODIFIER_LIST:[public] + VALUE_PARAMETER_LIST: + CLASS_BODY: diff --git a/idea/testData/decompiler/stubBuilder/NestedClasses/NestedClasses.txt b/idea/testData/decompiler/stubBuilder/NestedClasses/NestedClasses.txt index 41a5d1424ee..192857c41af 100644 --- a/idea/testData/decompiler/stubBuilder/NestedClasses/NestedClasses.txt +++ b/idea/testData/decompiler/stubBuilder/NestedClasses/NestedClasses.txt @@ -71,7 +71,17 @@ PsiJetFileStubImpl[package=test] USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=test] REFERENCE_EXPRESSION:[referencedName=NestedClasses] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=TOuter] REFERENCE_EXPRESSION:[referencedName=Inner] + TYPE_ARGUMENT_LIST: + TYPE_PROJECTION:[projectionKind=NONE] + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=TI] REFERENCE_EXPRESSION:[referencedName=II] TYPE_ARGUMENT_LIST: TYPE_PROJECTION:[projectionKind=NONE] diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java index bb075b52f58..e50c31cfc47 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java @@ -107,6 +107,12 @@ public class ClsStubBuilderTestGenerated extends AbstractClsStubBuilderTest { doTest(fileName); } + @TestMetadata("InnerTypes") + public void testInnerTypes() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/InnerTypes/"); + doTest(fileName); + } + @TestMetadata("LocalClass") public void testLocalClass() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/LocalClass/"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java index 3b1b50ec033..4eed32c5c9f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java @@ -43,6 +43,12 @@ public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCom doTest(fileName); } + @TestMetadata("InnerClasses") + public void ignoredInnerClasses() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/InnerClasses/"); + doTest(fileName); + } + @TestMetadata("NestedClasses") public void ignoredNestedClasses() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/NestedClasses/"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextTestGenerated.java index 6a2babb7b24..15f7bb10192 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextTestGenerated.java @@ -95,6 +95,12 @@ public class CommonDecompiledTextTestGenerated extends AbstractCommonDecompiledT doTest(fileName); } + @TestMetadata("InnerClasses") + public void testInnerClasses() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/InnerClasses/"); + doTest(fileName); + } + @TestMetadata("Modifiers") public void testModifiers() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/Modifiers/");