Cls stubs and decompiled text: Do not render parameter names in decompiled text and do not load ParameterName annotation in stubs
Add tests for decompiled text and stubs
This commit is contained in:
committed by
Valentin Kipyatkov
parent
86495fd136
commit
14f3e4c758
+4
-1
@@ -41,6 +41,9 @@ import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||
import java.util.*
|
||||
|
||||
// TODO: see DescriptorRendererOptions.excludedTypeAnnotationClasses for decompiler
|
||||
private val ANNOTATIONS_NOT_LOADED_FOR_TYPES = (ANNOTATIONS_COPIED_TO_TYPES + KotlinBuiltIns.FQ_NAMES.parameterName).toSet()
|
||||
|
||||
class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
|
||||
fun createTypeReferenceStub(parent: StubElement<out PsiElement>, type: Type) {
|
||||
@@ -49,7 +52,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
|
||||
val annotations = c.components.annotationLoader.loadTypeAnnotations(type, c.nameResolver).filterNot {
|
||||
val isTopLevelClass = !it.isNestedClass
|
||||
isTopLevelClass && it.asSingleFqName() in ANNOTATIONS_COPIED_TO_TYPES
|
||||
isTopLevelClass && it.asSingleFqName() in ANNOTATIONS_NOT_LOADED_FOR_TYPES
|
||||
}
|
||||
|
||||
val effectiveParent =
|
||||
|
||||
+3
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.idea.decompiler.textBuilder
|
||||
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.ByDescriptorIndexer
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -38,8 +39,9 @@ fun DescriptorRendererOptions.defaultDecompilerRendererOptions() {
|
||||
classWithPrimaryConstructor = true
|
||||
secondaryConstructorsAsPrimary = false
|
||||
modifiers = DescriptorRendererModifier.ALL
|
||||
excludedTypeAnnotationClasses = ExcludedTypeAnnotations.annotationsForNullabilityAndMutability
|
||||
excludedTypeAnnotationClasses = (ExcludedTypeAnnotations.annotationsForNullabilityAndMutability + KotlinBuiltIns.FQ_NAMES.parameterName).toSet()
|
||||
alwaysRenderModifiers = true
|
||||
parameterNamesInFunctionalTypes = false // to support parameters names in decompiled text we need to load annotation arguments
|
||||
}
|
||||
|
||||
fun buildDecompiledText(
|
||||
|
||||
Reference in New Issue
Block a user