Don't show local/anonymous classes in libraries in Project view
This commit is contained in:
@@ -16,13 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler
|
||||
|
||||
import com.intellij.ide.highlighter.JavaClassFileType
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.ClassFileViewProvider
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinClass
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticClass
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import com.intellij.psi.ClassFileViewProvider
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticClass
|
||||
import com.intellij.ide.highlighter.JavaClassFileType
|
||||
|
||||
/**
|
||||
* Checks if this file is a compiled Kotlin class file (not necessarily ABI-compatible with the current plugin)
|
||||
*/
|
||||
public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
|
||||
if (file.getExtension() != JavaClassFileType.INSTANCE!!.getDefaultExtension()) {
|
||||
return false
|
||||
@@ -34,6 +38,9 @@ public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
|
||||
header.syntheticClassKind != KotlinSyntheticClass.Kind.LOCAL_TRAIT_IMPL
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this file is a compiled Kotlin class file ABI-compatible with the current plugin
|
||||
*/
|
||||
public fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean {
|
||||
if (!isKotlinCompiledFile(file)) return false
|
||||
|
||||
@@ -41,6 +48,10 @@ public fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean {
|
||||
return header != null && header.isCompatibleAbiVersion
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this file is a compiled "internal" Kotlin class, i.e. a Kotlin class (not necessarily ABI-compatible with the current plugin)
|
||||
* which should NOT be decompiled (and, as a result, shown under the library in the Project view, be searchable via Find class, etc.)
|
||||
*/
|
||||
public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean {
|
||||
if (!isKotlinCompiledFile(file)) {
|
||||
return false
|
||||
@@ -49,6 +60,7 @@ public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean {
|
||||
if (ClassFileViewProvider.isInnerClass(file)) {
|
||||
return true
|
||||
}
|
||||
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader()
|
||||
return header?.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS
|
||||
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader() ?: return false
|
||||
return header.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS ||
|
||||
(header.kind == KotlinClassHeader.Kind.CLASS && header.classKind != null && header.classKind != KotlinClass.Kind.CLASS)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user