Prevent KotlinDecompiledFileViewProvider from reading vfile when possible
This commit is contained in:
+7
-2
@@ -49,12 +49,17 @@ fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean {
|
||||
* 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.)
|
||||
*/
|
||||
fun isKotlinInternalCompiledFile(file: VirtualFile, fileContent: ByteArray): Boolean {
|
||||
fun isKotlinInternalCompiledFile(file: VirtualFile, fileContent: ByteArray? = null): Boolean {
|
||||
if (!IDEKotlinBinaryClassCache.isKotlinJvmCompiledFile(file, fileContent)) {
|
||||
return false
|
||||
}
|
||||
|
||||
val innerClass = ClassFileViewProvider.isInnerClass(file, fileContent)
|
||||
val innerClass =
|
||||
if (fileContent == null)
|
||||
ClassFileViewProvider.isInnerClass(file)
|
||||
else
|
||||
ClassFileViewProvider.isInnerClass(file, fileContent)
|
||||
|
||||
if (innerClass) {
|
||||
return true
|
||||
}
|
||||
|
||||
+1
-7
@@ -52,14 +52,8 @@ class KotlinClassFileDecompiler : ClassFileDecompilers.Full() {
|
||||
val virtualFile = provider.virtualFile
|
||||
val fileIndex = ServiceManager.getService(project, FileIndexFacade::class.java)
|
||||
if (!fileIndex.isInLibraryClasses(virtualFile) && fileIndex.isInSource(virtualFile)) return@factory null
|
||||
val content = try {
|
||||
virtualFile.contentsToByteArray(false)
|
||||
}
|
||||
catch (e: IOException) {
|
||||
return@factory null
|
||||
}
|
||||
|
||||
if (isKotlinInternalCompiledFile(virtualFile, content))
|
||||
if (isKotlinInternalCompiledFile(virtualFile))
|
||||
null
|
||||
else
|
||||
KtClsFile(provider)
|
||||
|
||||
Reference in New Issue
Block a user