More efficient implementation of containsFilesWithExactPackage() (don't materialize KtFile instances we don't actually need)
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
<orderEntry type="library" scope="PROVIDED" name="java-i18n" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="java-i18n" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="gradle-and-groovy-plugin" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="gradle-and-groovy-plugin" level="project" />
|
||||||
<orderEntry type="module" module-name="eval4j" />
|
<orderEntry type="module" module-name="eval4j" />
|
||||||
<orderEntry type="library" exported="" name="intellij-core-analysis" level="project" />
|
|
||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
@@ -35,5 +34,6 @@
|
|||||||
<orderEntry type="module" module-name="idea-jps-common" />
|
<orderEntry type="module" module-name="idea-jps-common" />
|
||||||
<orderEntry type="module" module-name="cli-common" />
|
<orderEntry type="module" module-name="cli-common" />
|
||||||
<orderEntry type="module" module-name="descriptors" />
|
<orderEntry type="module" module-name="descriptors" />
|
||||||
|
<orderEntry type="library" exported="" name="idea-full" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.idea.stubindex
|
package org.jetbrains.kotlin.idea.stubindex
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS
|
||||||
|
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import com.intellij.psi.stubs.StubIndex
|
import com.intellij.psi.stubs.StubIndex
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -60,13 +62,17 @@ object PackageIndexUtil {
|
|||||||
searchScope: GlobalSearchScope,
|
searchScope: GlobalSearchScope,
|
||||||
project: Project
|
project: Project
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var result = false
|
val ids = StubIndex.getInstance().getContainingIds(KotlinExactPackagesIndex.getInstance().key,
|
||||||
StubIndex.getInstance().processElements<String, KtFile>(
|
packageFqName.asString(),
|
||||||
KotlinExactPackagesIndex.getInstance().key, packageFqName.asString(), project, searchScope, KtFile::class.java
|
project,
|
||||||
) {
|
searchScope)
|
||||||
result = true
|
val fs = PersistentFS.getInstance() as PersistentFSImpl
|
||||||
false
|
while (ids.hasNext()) {
|
||||||
|
val file = fs.findFileByIdIfCached(ids.next())
|
||||||
|
if (file != null && file in searchScope) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user