[FIR] Create context and scope for incremental compilation separately
Scope for incremental compilation refers to binaries from previous step of IC. It is used not only in IC context itself, but also it is subtracted from original libraries scope. Before previous commit there was such scheme: 1. create incremental compilation context for files of specific session 2. subtract IC scope from main libraries scope 3. use updated libraries scope to create library session 4. create all needed source session(s) So here was a side effect of creating new IC context, which 1. is smelling code, because it increases mind complexity 2. hard to implement with new session utilities So to fix this problem this commit changes the scheme above: 1. create IC scope and modify libraries scope 2. create libraries session 3. create source session(s) and IC context for them
This commit is contained in:
committed by
Space Team
parent
79e4df72bf
commit
8ccd7c7d12
+12
-10
@@ -339,18 +339,12 @@ private fun doCompileWithK2(
|
||||
val projectEnvironment = context.environment.toAbstractProjectEnvironment()
|
||||
val compilerEnvironment = ModuleCompilerEnvironment(projectEnvironment, diagnosticsReporter)
|
||||
|
||||
val sourcesScope = compilerEnvironment.projectEnvironment.getSearchScopeBySourceFiles(sources)
|
||||
var librariesScope = projectEnvironment.getSearchScopeForProjectLibraries()
|
||||
val providerAndScopeForIncrementalCompilation = createContextForIncrementalCompilation(
|
||||
val incrementalCompilationScope = createIncrementalCompilationScope(
|
||||
compilerInput.configuration,
|
||||
projectEnvironment,
|
||||
sourcesScope,
|
||||
emptyList(),
|
||||
null
|
||||
)?.also { (_, _, precompiledBinariesFileScope) ->
|
||||
precompiledBinariesFileScope?.let { librariesScope -= it }
|
||||
}
|
||||
|
||||
incrementalExcludesScope = null
|
||||
)?.also { librariesScope -= it }
|
||||
val extensionRegistrars = (projectEnvironment as? VfsBasedProjectEnvironment)
|
||||
?.let { FirExtensionRegistrar.getInstances(it.project) }
|
||||
.orEmpty()
|
||||
@@ -364,7 +358,15 @@ private fun doCompileWithK2(
|
||||
val session = prepareJvmSessions(
|
||||
sourceFiles, kotlinCompilerConfiguration, projectEnvironment, rootModuleName, extensionRegistrars,
|
||||
librariesScope, libraryList, isCommonSourceForPsi, fileBelongsToModuleForPsi,
|
||||
createProviderAndScopeForIncrementalCompilation = { providerAndScopeForIncrementalCompilation }
|
||||
createProviderAndScopeForIncrementalCompilation = { files ->
|
||||
createContextForIncrementalCompilation(
|
||||
compilerInput.configuration,
|
||||
projectEnvironment,
|
||||
compilerEnvironment.projectEnvironment.getSearchScopeBySourceFiles(files.map { KtPsiSourceFile(it) }),
|
||||
emptyList(),
|
||||
incrementalCompilationScope
|
||||
)
|
||||
}
|
||||
).single().session
|
||||
|
||||
session.scriptDefinitionProviderService?.run {
|
||||
|
||||
Reference in New Issue
Block a user