[Resolve] Introduce an ability to get all moduleInfos without filtering by platform
Previously, each ProjectResolutionFacade was tied to the respective platform, so there were no point in collection moduleInfos for all possible platforms. For composite resolution mode, we have to get all modules no matter what their platform is (because all modules will be analyzed in one facade), so this commit adds such an ability.
This commit is contained in:
+8
-2
@@ -19,12 +19,16 @@ import org.jetbrains.kotlin.platform.isCommon
|
||||
import org.jetbrains.kotlin.types.typeUtil.closure
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
fun getModuleInfosFromIdeaModel(project: Project, platform: TargetPlatform): List<IdeaModuleInfo> {
|
||||
/** null-platform means that we should get all modules */
|
||||
fun getModuleInfosFromIdeaModel(project: Project, platform: TargetPlatform? = null): List<IdeaModuleInfo> {
|
||||
val modelInfosCache = project.cacheInvalidatingOnRootModifications {
|
||||
collectModuleInfosFromIdeaModel(project)
|
||||
}
|
||||
|
||||
return modelInfosCache.forPlatform(platform)
|
||||
return if (platform != null)
|
||||
modelInfosCache.forPlatform(platform)
|
||||
else
|
||||
modelInfosCache.allModules()
|
||||
}
|
||||
|
||||
private class IdeaModelInfosCache(
|
||||
@@ -39,6 +43,8 @@ private class IdeaModelInfosCache(
|
||||
mergePlatformModules(moduleSourceInfos, platform) + libraryInfos + sdkInfos
|
||||
}
|
||||
}
|
||||
|
||||
fun allModules(): List<IdeaModuleInfo> = moduleSourceInfos + libraryInfos + sdkInfos
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -116,7 +116,8 @@ internal class ProjectResolutionFacade(
|
||||
projectContext
|
||||
)
|
||||
|
||||
val allModuleInfos = (allModules ?: getModuleInfosFromIdeaModel(project, settings.platform)).toMutableSet()
|
||||
val allModuleInfos = (allModules ?: getModuleInfosFromIdeaModel(project, (settings as? PlatformAnalysisSettingsImpl)?.platform))
|
||||
.toMutableSet()
|
||||
|
||||
val syntheticFilesByModule = syntheticFiles.groupBy(KtFile::getModuleInfo)
|
||||
val syntheticFilesModules = syntheticFilesByModule.keys
|
||||
@@ -166,7 +167,7 @@ internal class ProjectResolutionFacade(
|
||||
},
|
||||
builtIns = builtIns,
|
||||
delegateResolver = delegateResolverForProject,
|
||||
firstDependency = settings.sdk?.let { SdkInfo(project, it) },
|
||||
firstDependency = (settings as PlatformAnalysisSettingsImpl).sdk?.let { SdkInfo(project, it) },
|
||||
packageOracleFactory = ServiceManager.getService(project, IdePackageOracleFactory::class.java),
|
||||
invalidateOnOOCB = invalidateOnOOCB,
|
||||
isReleaseCoroutines = settings.isReleaseCoroutines
|
||||
|
||||
Reference in New Issue
Block a user