Optimize top level class searching in LazyJavaPackageScope
Do not try to search something, that is known not to exist
This commit is contained in:
@@ -20,9 +20,7 @@ import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.util.containers.IntArrayList
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import java.util.ArrayList
|
||||
import java.util.EnumSet
|
||||
import java.util.HashMap
|
||||
import java.util.*
|
||||
|
||||
data class JavaRoot(val file: VirtualFile, val type: JavaRoot.RootType, val prefixFqName: FqName? = null) {
|
||||
enum class RootType {
|
||||
@@ -99,6 +97,24 @@ class JvmDependenciesIndex(_roots: List<JavaRoot>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun collectKnownClassNamesInPackage(
|
||||
packageFqName: FqName
|
||||
): Set<String> {
|
||||
var result = hashSetOf<String>()
|
||||
traverseDirectoriesInPackage(packageFqName, continueSearch = {
|
||||
dir, rootType ->
|
||||
|
||||
for (child in dir.children) {
|
||||
if (child.extension != "class" && child.extension != "java") continue
|
||||
result.add(child.nameWithoutExtension)
|
||||
}
|
||||
|
||||
true
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private data class HandleResult<T : Any>(val result: T?, val continueSearch: Boolean)
|
||||
|
||||
private fun <T : Any> search(
|
||||
|
||||
@@ -120,6 +120,8 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager)
|
||||
return findClassInPsiFile(classNameWithInnerClasses, file)
|
||||
}
|
||||
|
||||
override fun knownClassNamesInPackage(packageFqName: FqName) = index.collectKnownClassNamesInPackage(packageFqName)
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(KotlinCliJavaFileManagerImpl::class.java)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user