IJ file type optimizations based on extension
#KTIJ-21668 Merge-request: KT-MR-6288 Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
This commit is contained in:
committed by
Space
parent
4a6466e290
commit
efd5beb49b
@@ -314,7 +314,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
private val VirtualFile.javaFiles: List<VirtualFile>
|
||||
get() = mutableListOf<VirtualFile>().apply {
|
||||
VfsUtilCore.processFilesRecursively(this@javaFiles) { file ->
|
||||
if (file.fileType == JavaFileType.INSTANCE) {
|
||||
if (file.extension == JavaFileType.DEFAULT_EXTENSION || file.fileType == JavaFileType.INSTANCE) {
|
||||
add(file)
|
||||
}
|
||||
true
|
||||
|
||||
+1
-1
@@ -310,7 +310,7 @@ object TopDownAnalyzerFacadeForJVM {
|
||||
// 'isDirectory' check is needed because otherwise directories such as 'frontend.java' would be recognized
|
||||
// as Java source files, which makes no sense
|
||||
override fun contains(file: VirtualFile) =
|
||||
file.fileType === JavaFileType.INSTANCE && !file.isDirectory
|
||||
(file.extension == JavaFileType.DEFAULT_EXTENSION || file.fileType === JavaFileType.INSTANCE) && !file.isDirectory
|
||||
|
||||
override fun toString() = "All Java sources in the project"
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ inline fun List<KotlinSourceRoot>.forAllFiles(
|
||||
continue
|
||||
}
|
||||
|
||||
if (!vFile.isDirectory && vFile.fileType != KotlinFileType.INSTANCE) {
|
||||
if (!vFile.isDirectory && vFile.extension != KotlinFileType.EXTENSION && vFile.fileType != KotlinFileType.INSTANCE) {
|
||||
configuration.report(CompilerMessageSeverity.ERROR, "Source entry is not a Kotlin file: $sourceRootPath", reportLocation)
|
||||
continue
|
||||
}
|
||||
|
||||
+3
-1
@@ -62,7 +62,9 @@ class KotlinBinaryClassCache : Disposable {
|
||||
fun getKotlinBinaryClassOrClassFileContent(
|
||||
file: VirtualFile, fileContent: ByteArray? = null
|
||||
): KotlinClassFinder.Result? {
|
||||
if (file.fileType !== JavaClassFileType.INSTANCE) return null
|
||||
if (file.extension != JavaClassFileType.INSTANCE.defaultExtension &&
|
||||
file.fileType !== JavaClassFileType.INSTANCE
|
||||
) return null
|
||||
|
||||
if (file.name == PsiJavaModule.MODULE_INFO_CLS_FILE) return null
|
||||
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ import com.intellij.ide.highlighter.JavaClassFileType
|
||||
import com.intellij.openapi.diagnostic.ControlFlowException
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder.Result.KotlinClass
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -49,7 +48,7 @@ class VirtualFileKotlinClass private constructor(
|
||||
|
||||
internal fun create(file: VirtualFile, fileContent: ByteArray?): KotlinClassFinder.Result? {
|
||||
return perfCounter.time {
|
||||
assert(file.fileType == JavaClassFileType.INSTANCE) { "Trying to read binary data from a non-class file $file" }
|
||||
assert(file.extension == JavaClassFileType.INSTANCE.defaultExtension || file.fileType == JavaClassFileType.INSTANCE) { "Trying to read binary data from a non-class file $file" }
|
||||
|
||||
try {
|
||||
val byteContent = fileContent ?: file.contentsToByteArray(false)
|
||||
|
||||
@@ -90,7 +90,7 @@ interface JavaModule {
|
||||
get() = moduleInfo.moduleName
|
||||
|
||||
override val isSourceModule: Boolean
|
||||
get() = moduleInfoFile.fileType == JavaFileType.INSTANCE
|
||||
get() = moduleInfoFile.extension == JavaFileType.DEFAULT_EXTENSION || moduleInfoFile.fileType == JavaFileType.INSTANCE
|
||||
|
||||
override fun exports(packageFqName: FqName): Boolean {
|
||||
return moduleInfo.exports.any { (fqName, toModules) ->
|
||||
|
||||
Reference in New Issue
Block a user