diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt index 8573b0e4339..3efae6433e6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt @@ -16,6 +16,7 @@ import com.intellij.openapi.roots.impl.libraries.LibraryEx import com.intellij.openapi.roots.libraries.Library import com.intellij.openapi.util.ModificationTracker import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.ResolveScopeEnlarger import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.util.CachedValueProvider import com.intellij.util.PathUtil @@ -58,6 +59,14 @@ interface IdeaModuleInfo : org.jetbrains.kotlin.idea.caches.resolve.IdeaModuleIn override fun dependencies(): List } +private fun enlargedSearchScope(searchScope: GlobalSearchScope, moduleFile: VirtualFile?): GlobalSearchScope { + if (moduleFile == null) return searchScope + return ResolveScopeEnlarger.EP_NAME.extensions.fold(searchScope) { scope, enlarger -> + val extra = enlarger.getAdditionalResolveScope(moduleFile, scope.project) + if (extra != null) scope.union(extra) else scope + } +} + private fun orderEntryToModuleInfo(project: Project, orderEntry: OrderEntry, forProduction: Boolean): List { fun Module.toInfos() = correspondingModuleInfos().filter { !forProduction || it is ModuleProductionSourceInfo } @@ -161,7 +170,7 @@ data class ModuleProductionSourceInfo internal constructor( override val stableName: Name = module.getStableName() - override fun contentScope(): GlobalSearchScope = ModuleProductionSourceScope(module) + override fun contentScope(): GlobalSearchScope = enlargedSearchScope(ModuleProductionSourceScope(module), module.moduleFile) override fun createCachedValueProvider(f: () -> CachedValueProvider.Result) = CachedValueProvider { f() } } @@ -177,7 +186,7 @@ data class ModuleTestSourceInfo internal constructor(override val module: Module override val displayedName get() = module.name + " (test)" - override fun contentScope(): GlobalSearchScope = ModuleTestSourceScope(module) + override fun contentScope(): GlobalSearchScope = enlargedSearchScope(ModuleTestSourceScope(module), module.moduleFile) override fun modulesWhoseInternalsAreVisible() = module.cached(CachedValueProvider { val list = SmartList() @@ -433,4 +442,4 @@ data class PlatformModuleInfo( } fun IdeaModuleInfo.projectSourceModules(): List? = - (this as? ModuleSourceInfo)?.let(::listOf) ?: (this as? PlatformModuleInfo)?.containedModules \ No newline at end of file + (this as? ModuleSourceInfo)?.let(::listOf) ?: (this as? PlatformModuleInfo)?.containedModules