Introduce AbstractResolverForProject
Previously, ResolverForProjectImpl had multiple callbacks in constructor. Some of those callbacks were used only to overcome module visibility and provide an ability to inject IDE-specific logic into compiler (ResolverForProject is in the 'compiler'-module) This commit introduces abstract class which implements environment-independent logic (previously, this logic had been stored in ResolverForProjectImpl) with several abstract met hods (previously, callbacks). Then, we provide few concrete implementations of AbstractResolverForProject with clear semantics: - IdeaResolverForProject: resolver used in IDE, where we have indices, oracles, multiple modules, etc. - ResolverForSingleModuleProject: resolver for project with only one module, commonly used for CLI compiler/tests - one anonymous implementation for MultimoduleTests This refactoring achieves several things: - now it is easier to see what kinds of ResolverForProject you might see in some particular environment (previously, one had to inspect all call-sites of constructor) - we can easily add IDE-specific logic in IdeaResolverForProject without adding noisy callbacks (which most probably wouldn't have any other non-trivial implementations)
This commit is contained in:
+8
-10
@@ -46,18 +46,16 @@ fun createResolveSessionForFiles(
|
||||
packagePartProviderFactory = { PackagePartProvider.Empty },
|
||||
moduleByJavaClass = { testModule }
|
||||
)
|
||||
val resolverForProject = ResolverForProjectImpl(
|
||||
|
||||
val resolverForProject = ResolverForSingleModuleProject(
|
||||
"test",
|
||||
projectContext, listOf(testModule),
|
||||
{ ModuleContent(it, syntheticFiles, GlobalSearchScope.allScope(project)) },
|
||||
invalidateOnOOCB = false,
|
||||
moduleLanguageSettingsProvider = LanguageSettingsProvider.Default,
|
||||
resolverForModuleFactoryByPlatform = {
|
||||
JvmResolverForModuleFactory(platformParameters, CompilerEnvironment, JvmPlatforms.defaultJvmPlatform)
|
||||
},
|
||||
builtInsProvider = { DefaultBuiltIns.Instance },
|
||||
sdkDependency = { null }
|
||||
projectContext,
|
||||
testModule,
|
||||
JvmResolverForModuleFactory(platformParameters, CompilerEnvironment, JvmPlatforms.defaultJvmPlatform),
|
||||
GlobalSearchScope.allScope(project),
|
||||
syntheticFiles = syntheticFiles
|
||||
)
|
||||
|
||||
return resolverForProject.resolverForModule(testModule).componentProvider.get<ResolveSession>()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user