DecompiledTextFactory: add buildDecompiledTextFromJSMetadata
This commit is contained in:
+20
@@ -18,7 +18,12 @@ package org.jetbrains.kotlin.idea.decompiler.textBuilder
|
||||
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.JsMetaFileVirtualFileHolder
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
@@ -71,6 +76,21 @@ public fun buildDecompiledText(
|
||||
}
|
||||
}
|
||||
|
||||
public fun buildDecompiledTextFromJsMetadata(
|
||||
classFile: VirtualFile
|
||||
): DecompiledText {
|
||||
val module = classFile.getUserData(JsMetaFileVirtualFileHolder.MODULE_DESCRIPTOR_KEY)
|
||||
assert(module != null)
|
||||
|
||||
val packageFqName = classFile.getUserData(JsMetaFileVirtualFileHolder.PACKAGE_FQNAME_KEY)
|
||||
assert (packageFqName != null)
|
||||
|
||||
val fragments = module.getPackageFragmentProvider().getPackageFragments(packageFqName)
|
||||
val descriptors = fragments.flatMap { it.getMemberScope().getAllDescriptors() }
|
||||
|
||||
return buildDecompiledText(packageFqName, descriptors)
|
||||
}
|
||||
|
||||
private val DECOMPILED_CODE_COMMENT = "/* compiled code */"
|
||||
private val DECOMPILED_COMMENT_FOR_PARAMETER = "/* = compiled code */"
|
||||
private val FLEXIBLE_TYPE_COMMENT = "/* platform type */"
|
||||
|
||||
Reference in New Issue
Block a user