Support different target platforms for modules in AnalyzerFacade
Instead of reusing the same AnalyzerFacade that is used for resolution of a module to resolve its dependencies, analyze each dependency module/library with a facade depending on its target platform. Introduce and use CommonLibraryDetectionUtil in addition to KotlinJavaScriptLibraryDetectionUtil, to detect common libraries (with .kotlin_metadata files). Note that before multi-platform projects, this was not needed because there were only two platforms (JVM and JS), and JVM module had only JVM modules/libraries as dependencies, JS module had only JS modules/libraries as dependencies. Now, for example, a JVM module can have a common module/library as a dependency, and it would be incorrect to analyze that dependency with JvmAnalyzerFacade because that facade does not know anything about .kotlin_metadata files. The changes in Dsl.kt and KotlinCacheServiceImpl.kt are needed because PsiElement.getJavaDescriptorResolver, called from some IDE code, started to fail on a common module, because the container for a common module does not have the JavaDescriptorResolver
This commit is contained in:
+3
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.jvm.compiler
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.search.DelegatingGlobalSearchScope
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analyzer.AnalyzerFacade
|
||||
import org.jetbrains.kotlin.analyzer.ModuleContent
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ResolverForProject
|
||||
@@ -65,9 +66,9 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
|
||||
val modules = setupModules(environment, moduleDirs)
|
||||
val projectContext = ProjectContext(environment.project)
|
||||
val builtIns = JvmBuiltIns(projectContext.storageManager)
|
||||
val resolverForProject = JvmAnalyzerFacade.setupResolverForProject(
|
||||
val resolverForProject = AnalyzerFacade.setupResolverForProject(
|
||||
"test",
|
||||
projectContext, modules,
|
||||
projectContext, modules, { JvmAnalyzerFacade },
|
||||
{ module -> ModuleContent(module.kotlinFiles, module.javaFilesScope) },
|
||||
JvmPlatformParameters {
|
||||
javaClass ->
|
||||
|
||||
Reference in New Issue
Block a user