Decompiler & stub builder fixed accordingly with new enum syntax.
Companion object now directly follows enum entries to avoid having them at the middle. Some decompiler & stub builder tests fixed accordingly.
This commit is contained in:
+1
-1
@@ -161,8 +161,8 @@ private class ClassClsStubBuilder(
|
|||||||
|
|
||||||
private fun createClassBodyAndMemberStubs() {
|
private fun createClassBodyAndMemberStubs() {
|
||||||
val classBody = KotlinPlaceHolderStubImpl<JetClassBody>(classOrObjectStub, JetStubElementTypes.CLASS_BODY)
|
val classBody = KotlinPlaceHolderStubImpl<JetClassBody>(classOrObjectStub, JetStubElementTypes.CLASS_BODY)
|
||||||
createCompanionObjectStub(classBody)
|
|
||||||
createEnumEntryStubs(classBody)
|
createEnumEntryStubs(classBody)
|
||||||
|
createCompanionObjectStub(classBody)
|
||||||
createCallableMemberStubs(classBody)
|
createCallableMemberStubs(classBody)
|
||||||
createInnerAndNestedClasses(classBody)
|
createInnerAndNestedClasses(classBody)
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-13
@@ -169,13 +169,17 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
|||||||
builder.append(" {\n")
|
builder.append(" {\n")
|
||||||
var firstPassed = false
|
var firstPassed = false
|
||||||
val subindent = indent + " "
|
val subindent = indent + " "
|
||||||
val companionObject = descriptor.getCompanionObjectDescriptor()
|
|
||||||
if (companionObject != null) {
|
|
||||||
firstPassed = true
|
|
||||||
builder.append(subindent)
|
|
||||||
appendDescriptor(companionObject, subindent)
|
|
||||||
}
|
|
||||||
val allDescriptors = descriptor.secondaryConstructors + descriptor.getDefaultType().getMemberScope().getDescriptors()
|
val allDescriptors = descriptor.secondaryConstructors + descriptor.getDefaultType().getMemberScope().getDescriptors()
|
||||||
|
val companionObject = descriptor.getCompanionObjectDescriptor()
|
||||||
|
var companionNeeded = (companionObject != null)
|
||||||
|
fun newlineExceptFirst() {
|
||||||
|
if (firstPassed) {
|
||||||
|
builder.append("\n")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
firstPassed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
for (member in allDescriptors) {
|
for (member in allDescriptors) {
|
||||||
if (member.getContainingDeclaration() != descriptor) {
|
if (member.getContainingDeclaration() != descriptor) {
|
||||||
continue
|
continue
|
||||||
@@ -183,19 +187,19 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
|||||||
if (member == companionObject) {
|
if (member == companionObject) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if (companionNeeded && !isEnumEntry(member)) {
|
||||||
|
companionNeeded = false
|
||||||
|
newlineExceptFirst()
|
||||||
|
builder.append(subindent)
|
||||||
|
appendDescriptor(companionObject, subindent)
|
||||||
|
}
|
||||||
if (member is CallableMemberDescriptor
|
if (member is CallableMemberDescriptor
|
||||||
&& member.getKind() != CallableMemberDescriptor.Kind.DECLARATION
|
&& member.getKind() != CallableMemberDescriptor.Kind.DECLARATION
|
||||||
//TODO: not synthesized and component like
|
//TODO: not synthesized and component like
|
||||||
&& !isComponentLike(member.getName())) {
|
&& !isComponentLike(member.getName())) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
newlineExceptFirst()
|
||||||
if (firstPassed) {
|
|
||||||
builder.append("\n")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
firstPassed = true
|
|
||||||
}
|
|
||||||
builder.append(subindent)
|
builder.append(subindent)
|
||||||
appendDescriptor(member, subindent)
|
appendDescriptor(member, subindent)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,22 @@
|
|||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
public final enum class Enum private () : kotlin.Enum<test.Enum>, dependency.Tr {
|
internal final enum class Enum private () : kotlin.Enum<test.Enum> {
|
||||||
ONE
|
A
|
||||||
|
|
||||||
TWO
|
B
|
||||||
|
|
||||||
THREE
|
C
|
||||||
|
|
||||||
|
D
|
||||||
|
|
||||||
|
E
|
||||||
|
|
||||||
|
F
|
||||||
|
|
||||||
|
internal companion object {
|
||||||
|
internal final val c: kotlin.Int /* compiled code */
|
||||||
|
}
|
||||||
|
|
||||||
|
internal open fun f(): kotlin.Int { /* compiled code */ }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package test
|
|||||||
|
|
||||||
import dependency.*
|
import dependency.*
|
||||||
|
|
||||||
public enum class Enum : Tr {
|
enum class Enum {
|
||||||
ONE
|
A B C D E F {
|
||||||
TWO
|
override fun f() = 4
|
||||||
THREE {
|
|
||||||
fun g() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val c: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun f() = 3
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ PsiJetFileStubImpl[package=a.b.c.test.enum]
|
|||||||
REFERENCE_EXPRESSION:[referencedName=enum]
|
REFERENCE_EXPRESSION:[referencedName=enum]
|
||||||
REFERENCE_EXPRESSION:[referencedName=Enum]
|
REFERENCE_EXPRESSION:[referencedName=Enum]
|
||||||
CLASS_BODY:
|
CLASS_BODY:
|
||||||
|
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.A, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=A, superNames=[]]
|
||||||
|
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.B, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=B, superNames=[]]
|
||||||
|
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.C, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=C, superNames=[]]
|
||||||
|
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.D, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=D, superNames=[]]
|
||||||
|
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.E, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=E, superNames=[]]
|
||||||
|
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.F, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=F, superNames=[]]
|
||||||
OBJECT_DECLARATION:[fqName=a.b.c.test.enum.Enum.Companion, isCompanion=true, isLocal=false, isObjectLiteral=false, isTopLevel=false, name=Companion, superNames=[]]
|
OBJECT_DECLARATION:[fqName=a.b.c.test.enum.Enum.Companion, isCompanion=true, isLocal=false, isObjectLiteral=false, isTopLevel=false, name=Companion, superNames=[]]
|
||||||
MODIFIER_LIST:[internal companion]
|
MODIFIER_LIST:[internal companion]
|
||||||
CLASS_BODY:
|
CLASS_BODY:
|
||||||
@@ -47,12 +53,6 @@ PsiJetFileStubImpl[package=a.b.c.test.enum]
|
|||||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||||
REFERENCE_EXPRESSION:[referencedName=Int]
|
REFERENCE_EXPRESSION:[referencedName=Int]
|
||||||
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.A, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=A, superNames=[]]
|
|
||||||
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.B, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=B, superNames=[]]
|
|
||||||
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.C, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=C, superNames=[]]
|
|
||||||
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.D, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=D, superNames=[]]
|
|
||||||
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.E, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=E, superNames=[]]
|
|
||||||
ENUM_ENTRY:[fqName=a.b.c.test.enum.Enum.F, isEnumEntry=true, isInterface=false, isLocal=false, isTopLevel=false, name=F, superNames=[]]
|
|
||||||
FUN:[fqName=a.b.c.test.enum.Enum.f, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=f]
|
FUN:[fqName=a.b.c.test.enum.Enum.f, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=f]
|
||||||
MODIFIER_LIST:[open internal]
|
MODIFIER_LIST:[open internal]
|
||||||
VALUE_PARAMETER_LIST:
|
VALUE_PARAMETER_LIST:
|
||||||
|
|||||||
Reference in New Issue
Block a user