Move module creation into TopDownAnalyzerFacadeForJVM#analyzeFilesWithJavaIntegration
The only place where the logic has changed is in AbstractDiagnosticsTest, where modules are already created and sealed before the analysis. Copy-paste the container creation logic there (it's almost fine because it's also present in a bunch of other tests), and simplify it: get rid of incremental compilation and other stuff irrelevant for diagnostic tests. This is needed to make analyzeFilesWithJavaIntegration configure the module properly before sealing it
This commit is contained in:
@@ -128,10 +128,11 @@ fun createContainerForTopDownSingleModuleAnalyzerForJvm(
|
||||
bindingTrace: BindingTrace,
|
||||
declarationProviderFactory: DeclarationProviderFactory,
|
||||
moduleContentScope: GlobalSearchScope,
|
||||
packagePartProvider: PackagePartProvider
|
||||
packagePartProvider: PackagePartProvider,
|
||||
languageVersionSettings: LanguageVersionSettings = LanguageVersionSettingsImpl.DEFAULT
|
||||
): ComponentProvider = createContainerForTopDownAnalyzerForJvm(
|
||||
moduleContext, bindingTrace, declarationProviderFactory, moduleContentScope,
|
||||
LookupTracker.DO_NOTHING, packagePartProvider, LanguageVersionSettingsImpl.DEFAULT, SingleModuleClassResolver()
|
||||
LookupTracker.DO_NOTHING, packagePartProvider, languageVersionSettings, SingleModuleClassResolver()
|
||||
).apply {
|
||||
get<SingleModuleClassResolver>().resolver = get<JavaDescriptorResolver>()
|
||||
}
|
||||
|
||||
+2
-4
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.container.get
|
||||
import org.jetbrains.kotlin.context.ContextForNewModule
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
import org.jetbrains.kotlin.context.MutableModuleContext
|
||||
import org.jetbrains.kotlin.context.ProjectContext
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
@@ -53,14 +52,14 @@ import java.util.*
|
||||
object TopDownAnalyzerFacadeForJVM {
|
||||
@JvmStatic
|
||||
fun analyzeFilesWithJavaIntegration(
|
||||
moduleContext: ModuleContext,
|
||||
project: Project,
|
||||
files: Collection<KtFile>,
|
||||
trace: BindingTrace,
|
||||
configuration: CompilerConfiguration,
|
||||
packagePartProvider: PackagePartProvider
|
||||
): AnalysisResult {
|
||||
val moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, configuration)
|
||||
val storageManager = moduleContext.storageManager
|
||||
val project = moduleContext.project
|
||||
val module = moduleContext.module
|
||||
|
||||
val incrementalComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
|
||||
@@ -114,7 +113,6 @@ object TopDownAnalyzerFacadeForJVM {
|
||||
return AnalysisResult.success(trace.bindingContext, module)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun createContextWithSealedModule(project: Project, configuration: CompilerConfiguration): MutableModuleContext {
|
||||
val projectContext = ProjectContext(project)
|
||||
val builtIns = JvmBuiltIns(projectContext.storageManager)
|
||||
|
||||
Reference in New Issue
Block a user