com.jetbrains.plugin.structure.classes.utils.KtClassNode.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structure-classes Show documentation
Show all versions of structure-classes Show documentation
Base library for resolving class files and resources. Used by other JetBrains Plugins Structure Classes libraries.
package com.jetbrains.plugin.structure.classes.utils
import kotlinx.metadata.ClassKind
import kotlinx.metadata.KmClass
import kotlinx.metadata.Visibility
import kotlinx.metadata.jvm.KotlinClassMetadata
import kotlinx.metadata.jvm.signature
import kotlinx.metadata.kind
import kotlinx.metadata.visibility
import org.objectweb.asm.tree.ClassNode
class KtClassNode(private val classNode: ClassNode, private val metadata: KotlinClassMetadata.Class) {
val name: String
get() = classNode.name
val isInternal: Boolean
get() = cls.visibility == Visibility.INTERNAL
val isEnumClass: Boolean
get() = cls.kind == ClassKind.ENUM_CLASS
fun isInternalField(fieldName: String): Boolean {
return cls.properties.any { it.name == fieldName && it.visibility == Visibility.INTERNAL }
}
fun isInternalFunction(functionName: String, jvmDescriptor: String): Boolean {
return cls.functions.any { it.name == functionName
&& it.signature?.descriptor == jvmDescriptor
&& it.visibility == Visibility.INTERNAL }
}
private val cls: KmClass
get() = metadata.kmClass
}