Extend import resolution for library-to-source analysis

Use composite importing scope for references when resolution anchors are enabled.
Composite scope provides additional descriptors from scope of resolution anchor module.
Overriding old importing scope with a new one is not possible as it breaks library
dependencies on other libraries, which are inaccessible in anchor scope (scope for sources).

KT-24309 In Progress
This commit is contained in:
Pavel Kirpichenkov
2020-06-15 15:36:53 +03:00
parent 8c876e4621
commit 5892bdf3f4
8 changed files with 94 additions and 2 deletions
@@ -79,8 +79,11 @@ class KotlinIdeResolutionAnchorService(
override fun getResolutionAnchor(moduleDescriptor: ModuleDescriptor): ModuleDescriptor? {
if (!project.libraryToSourceAnalysisEnabled) return null
val moduleInfo = moduleDescriptor.moduleInfo ?: return null
val mapped = moduleToAnchor[moduleInfo] ?: return null
val keyModuleInfo = if (moduleInfo is SourceForBinaryModuleInfo) moduleInfo.binariesModuleInfo else moduleInfo
val mapped = moduleToAnchor[keyModuleInfo] ?: return null
return KotlinCacheService.getInstance(project)
.getResolutionFacadeByModuleInfo(mapped, mapped.platform)
?.moduleDescriptor
@@ -250,6 +250,9 @@ private fun MutableMap<AnalysisFlag<*>, Any>.initIDESpecificAnalysisSettings(pro
if (KotlinMultiplatformAnalysisModeComponent.getMode(project) == KotlinMultiplatformAnalysisModeComponent.Mode.COMPOSITE) {
put(AnalysisFlags.useTypeRefinement, true)
}
if (KotlinLibraryToSourceAnalysisComponent.isEnabled(project)) {
put(AnalysisFlags.libraryToSourceAnalysis, true)
}
put(AnalysisFlags.ideMode, true)
}