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() {
|
||||
val classBody = KotlinPlaceHolderStubImpl<JetClassBody>(classOrObjectStub, JetStubElementTypes.CLASS_BODY)
|
||||
createCompanionObjectStub(classBody)
|
||||
createEnumEntryStubs(classBody)
|
||||
createCompanionObjectStub(classBody)
|
||||
createCallableMemberStubs(classBody)
|
||||
createInnerAndNestedClasses(classBody)
|
||||
}
|
||||
|
||||
+17
-13
@@ -169,13 +169,17 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
||||
builder.append(" {\n")
|
||||
var firstPassed = false
|
||||
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 companionObject = descriptor.getCompanionObjectDescriptor()
|
||||
var companionNeeded = (companionObject != null)
|
||||
fun newlineExceptFirst() {
|
||||
if (firstPassed) {
|
||||
builder.append("\n")
|
||||
}
|
||||
else {
|
||||
firstPassed = true
|
||||
}
|
||||
}
|
||||
for (member in allDescriptors) {
|
||||
if (member.getContainingDeclaration() != descriptor) {
|
||||
continue
|
||||
@@ -183,19 +187,19 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
||||
if (member == companionObject) {
|
||||
continue
|
||||
}
|
||||
if (companionNeeded && !isEnumEntry(member)) {
|
||||
companionNeeded = false
|
||||
newlineExceptFirst()
|
||||
builder.append(subindent)
|
||||
appendDescriptor(companionObject, subindent)
|
||||
}
|
||||
if (member is CallableMemberDescriptor
|
||||
&& member.getKind() != CallableMemberDescriptor.Kind.DECLARATION
|
||||
//TODO: not synthesized and component like
|
||||
&& !isComponentLike(member.getName())) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (firstPassed) {
|
||||
builder.append("\n")
|
||||
}
|
||||
else {
|
||||
firstPassed = true
|
||||
}
|
||||
newlineExceptFirst()
|
||||
builder.append(subindent)
|
||||
appendDescriptor(member, subindent)
|
||||
}
|
||||
|
||||
@@ -3,10 +3,22 @@
|
||||
|
||||
package test
|
||||
|
||||
public final enum class Enum private () : kotlin.Enum<test.Enum>, dependency.Tr {
|
||||
ONE
|
||||
internal final enum class Enum private () : kotlin.Enum<test.Enum> {
|
||||
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.*
|
||||
|
||||
public enum class Enum : Tr {
|
||||
ONE
|
||||
TWO
|
||||
THREE {
|
||||
fun g() {
|
||||
}
|
||||
enum class Enum {
|
||||
A B C D E F {
|
||||
override fun f() = 4
|
||||
}
|
||||
|
||||
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]
|
||||
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=[]]
|
||||
MODIFIER_LIST:[internal companion]
|
||||
CLASS_BODY:
|
||||
@@ -47,12 +53,6 @@ PsiJetFileStubImpl[package=a.b.c.test.enum]
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
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]
|
||||
MODIFIER_LIST:[open internal]
|
||||
VALUE_PARAMETER_LIST:
|
||||
|
||||
Reference in New Issue
Block a user