Introduce const into decompiler and stub builder
This commit is contained in:
+7
-6
@@ -18,9 +18,7 @@ package org.jetbrains.kotlin.idea.decompiler.stubBuilder
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.FlagsToModifiers.MODALITY
|
||||
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.FlagsToModifiers.VISIBILITY
|
||||
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.FlagsToModifiers.*
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinClassStubImpl
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinFunctionStubImpl
|
||||
@@ -32,7 +30,6 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.MemberKind
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Modality
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
|
||||
|
||||
@@ -98,9 +95,13 @@ private class CallableClsStubBuilder(
|
||||
|
||||
private fun createModifierListStub() {
|
||||
val isModalityIrrelevant = isTopLevel || isConstructor
|
||||
val relevantModifiers = if (isModalityIrrelevant) listOf(VISIBILITY) else listOf(VISIBILITY, MODALITY)
|
||||
val modalityModifiers = if (isModalityIrrelevant) listOf() else listOf(MODALITY)
|
||||
val constModifiers = if (callableKind == CallableKind.VAL) listOf(CONST) else listOf()
|
||||
|
||||
val modifierListStubImpl = createModifierListStubForDeclaration(callableStub, callableProto.getFlags(), relevantModifiers)
|
||||
val relevantModifiers = listOf(VISIBILITY) + constModifiers + modalityModifiers
|
||||
val modifierListStubImpl = createModifierListStubForDeclaration(
|
||||
callableStub, callableProto.getFlags(), relevantModifiers
|
||||
)
|
||||
|
||||
val kind = callableProto.annotatedCallableKind
|
||||
val annotationIds = c.components.annotationLoader.loadCallableAnnotations(protoContainer, callableProto, c.nameResolver, kind)
|
||||
|
||||
+6
@@ -185,6 +185,12 @@ enum class FlagsToModifiers {
|
||||
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
||||
return if (Flags.INNER.get(flags)) JetTokens.INNER_KEYWORD else null
|
||||
}
|
||||
},
|
||||
|
||||
CONST {
|
||||
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
||||
return if (Flags.IS_CONST.get(flags)) JetTokens.CONST_KEYWORD else null
|
||||
}
|
||||
};
|
||||
|
||||
abstract fun getModifiers(flags: Int): JetModifierKeywordToken?
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package test
|
||||
|
||||
public object Const {
|
||||
private const final val inObject: kotlin.Int /* compiled code */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
object Const {
|
||||
const private val inObject = 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
object Const {
|
||||
const private val inObject = 1
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
PsiJetFileStubImpl[package=test]
|
||||
PACKAGE_DIRECTIVE:
|
||||
REFERENCE_EXPRESSION:[referencedName=test]
|
||||
IMPORT_LIST:
|
||||
OBJECT_DECLARATION:[fqName=test.Const, isCompanion=false, isLocal=false, isObjectLiteral=false, isTopLevel=true, name=Const, superNames=[]]
|
||||
MODIFIER_LIST:[public]
|
||||
CLASS_BODY:
|
||||
PROPERTY:[fqName=test.Const.inObject, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=inObject]
|
||||
MODIFIER_LIST:[private final const]
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Int]
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
PsiJetFileStubImpl[package=test]
|
||||
PACKAGE_DIRECTIVE:
|
||||
REFERENCE_EXPRESSION:[referencedName=test]
|
||||
IMPORT_LIST:
|
||||
OBJECT_DECLARATION:[fqName=test.Const, isCompanion=false, isLocal=false, isObjectLiteral=false, isTopLevel=true, name=Const, superNames=[]]
|
||||
CLASS_BODY:
|
||||
PROPERTY:[fqName=test.Const.inObject, hasDelegate=false, hasDelegateExpression=false, hasInitializer=true, hasReturnTypeRef=false, isExtension=false, isTopLevel=false, isVar=false, name=inObject]
|
||||
MODIFIER_LIST:[private const]
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
object Const {
|
||||
const private val inObject = 1
|
||||
}
|
||||
+6
@@ -65,6 +65,12 @@ public class ClsStubBuilderTestGenerated extends AbstractClsStubBuilderTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Const")
|
||||
public void testConst() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/Const/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DataClass")
|
||||
public void testDataClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/DataClass/");
|
||||
|
||||
+6
@@ -77,6 +77,12 @@ public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCom
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Const")
|
||||
public void testConst() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/Const/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Enum")
|
||||
public void testEnum() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/Enum/");
|
||||
|
||||
+6
@@ -53,6 +53,12 @@ public class CommonDecompiledTextTestGenerated extends AbstractCommonDecompiledT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Const")
|
||||
public void testConst() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/Const/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DependencyOnNestedClasses")
|
||||
public void testDependencyOnNestedClasses() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/DependencyOnNestedClasses/");
|
||||
|
||||
@@ -89,6 +89,12 @@ public class StubBuilderTestGenerated extends AbstractStubBuilderTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Const.kt")
|
||||
public void testConst() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/stubs/Const.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DanglingAnnotations.kt")
|
||||
public void testDanglingAnnotations() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/stubs/DanglingAnnotations.kt");
|
||||
|
||||
Reference in New Issue
Block a user