mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] migrate some usages of getOrderEntriesForFile to findContainingSdks/Libraries to improve performance (IJPL-930)
'getOrderEntriesForFile' builds 'OrderEntryGraph' for the whole project when called for the first time after a 'rootsChanged' event. This may lead to freezes, so it's much more efficient to use newly introduced 'findContainingSdks' and 'findContainingLibraries' methods from 'ProjectFileIndex' instead where it's possible. Semantics of code which used 'ModuleFileIndex' (not 'ProjectFileIndex') before may change if some file is part of an SDK in one module and part of a source code of another module, but in practice such cases shouldn't happen. GitOrigin-RevId: 57ee33df6fe10d4d90687d68245a7dba3e6b7b03
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cd899d9e2d
commit
d010a99375
@@ -3,8 +3,8 @@ package com.intellij.java.codeserver.core
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.roots.JdkOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.ProjectFileIndex
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
@@ -65,7 +65,7 @@ data class JpmsModuleAccessInfo(val current: JpmsModuleInfo.CurrentModuleInfo, v
|
||||
if (current.module == null) {
|
||||
val origin = targetModule.containingFile?.virtualFile
|
||||
if (origin == null || currentJpsModule == null ||
|
||||
ModuleRootManager.getInstance(currentJpsModule).fileIndex.getOrderEntryForFile(origin) !is JdkOrderEntry
|
||||
ProjectFileIndex.getInstance(currentJpsModule.project).findContainingSdks(origin).isEmpty()
|
||||
) {
|
||||
return null // a target is not on the mandatory module path
|
||||
}
|
||||
@@ -133,7 +133,7 @@ data class JpmsModuleAccessInfo(val current: JpmsModuleInfo.CurrentModuleInfo, v
|
||||
if (origin == null && targetModule is LightJavaModule) origin = targetModule.rootVirtualFile
|
||||
if (origin == null || currentJpsModule == null) return null
|
||||
|
||||
if (ModuleRootManager.getInstance(currentJpsModule).fileIndex.getOrderEntryForFile(origin) !is JdkOrderEntry) {
|
||||
if (ProjectFileIndex.getInstance(currentJpsModule.project).findContainingSdks(origin).isEmpty()) {
|
||||
val searchScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(currentJpsModule)
|
||||
if (searchScope.contains(origin)) return null
|
||||
return JpmsModuleAccessProblem.JPS_DEPENDENCY_PROBLEM
|
||||
@@ -248,10 +248,10 @@ data class JpmsModuleAccessInfo(val current: JpmsModuleInfo.CurrentModuleInfo, v
|
||||
if (target != null) {
|
||||
val useVFile = place.virtualFile
|
||||
if (useVFile != null) {
|
||||
val index = ModuleRootManager.getInstance(module).fileIndex
|
||||
val test = index.isInTestSourceContent(useVFile)
|
||||
val test = ModuleRootManager.getInstance(module).fileIndex.isInTestSourceContent(useVFile)
|
||||
val dirs = target.getDirectories(module.getModuleWithDependenciesAndLibrariesScope(test))
|
||||
return dirs.any { index.getOrderEntryForFile(it.virtualFile) !is JdkOrderEntry }
|
||||
val projectFileIndex = ProjectFileIndex.getInstance(module.project)
|
||||
return dirs.any { projectFileIndex.findContainingSdks(it.virtualFile).isEmpty() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user