From bafdf0b407dc82f4bd7d0adadc23ef3f742e7970 Mon Sep 17 00:00:00 2001 From: "Ivan.Yarkov" Date: Thu, 3 Oct 2024 13:45:56 +0300 Subject: [PATCH] RIDER-113376 provider custom Rider search scope, so it uses base project directories instead of content roots fixes "Go To Implementations" / "Go To Derived Symbols" action (cherry picked from commit 6b500d09250c5be63e9bcd90e4ca48bcfe913c90) IJ-MR-146194 GitOrigin-RevId: ca184640fda069a9aee880ca4455ccd588f863fd --- platform/analysis-impl/api-dump-unreviewed.txt | 1 + .../resources/META-INF/AnalysisImpl.xml | 2 ++ .../scopes/ModuleScopeProviderFactoryImpl.kt | 14 ++++++++++++++ .../impl/scopes/ModuleWithDependenciesScope.java | 2 +- .../module/impl/ModuleScopeProviderFactory.java | 16 ++++++++++++++++ .../intellij/openapi/module/impl/ModuleImpl.kt | 4 ++-- 6 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleScopeProviderFactoryImpl.kt create mode 100644 platform/core-impl/src/com/intellij/openapi/module/impl/ModuleScopeProviderFactory.java diff --git a/platform/analysis-impl/api-dump-unreviewed.txt b/platform/analysis-impl/api-dump-unreviewed.txt index 4cadc8d87b8d..ed24fdce5378 100644 --- a/platform/analysis-impl/api-dump-unreviewed.txt +++ b/platform/analysis-impl/api-dump-unreviewed.txt @@ -3306,6 +3306,7 @@ f:com.intellij.openapi.module.impl.scopes.ModuleWithDependenciesScope - equals(java.lang.Object):Z - extractFileEnumeration():com.intellij.psi.search.impl.VirtualFileEnumeration - getDisplayName():java.lang.String +- s:getFileEnumerationUnderRoots(java.util.Collection):com.intellij.psi.search.impl.VirtualFileEnumeration - getModule():com.intellij.openapi.module.Module - getRoots():java.util.Collection - isSearchInLibraries():Z diff --git a/platform/analysis-impl/resources/META-INF/AnalysisImpl.xml b/platform/analysis-impl/resources/META-INF/AnalysisImpl.xml index 95107df0805c..fb84923d8b44 100644 --- a/platform/analysis-impl/resources/META-INF/AnalysisImpl.xml +++ b/platform/analysis-impl/resources/META-INF/AnalysisImpl.xml @@ -55,6 +55,8 @@ serviceImplementation="com.intellij.psi.impl.search.PsiSearchHelperImpl"/> + diff --git a/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleScopeProviderFactoryImpl.kt b/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleScopeProviderFactoryImpl.kt new file mode 100644 index 000000000000..abdbd80052b1 --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleScopeProviderFactoryImpl.kt @@ -0,0 +1,14 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.module.impl.scopes + +import com.intellij.openapi.module.Module +import com.intellij.openapi.module.impl.ModuleScopeProvider +import com.intellij.openapi.module.impl.ModuleScopeProviderFactory +import org.jetbrains.annotations.ApiStatus + +@ApiStatus.Internal +open class ModuleScopeProviderFactoryImpl : ModuleScopeProviderFactory { + override fun createProvider(module: Module): ModuleScopeProvider { + return ModuleScopeProviderImpl(module) + } +} \ No newline at end of file diff --git a/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleWithDependenciesScope.java b/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleWithDependenciesScope.java index d66c1f056be6..29de2f684e4e 100644 --- a/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleWithDependenciesScope.java +++ b/platform/analysis-impl/src/com/intellij/openapi/module/impl/scopes/ModuleWithDependenciesScope.java @@ -196,7 +196,7 @@ public final class ModuleWithDependenciesScope extends GlobalSearchScope impleme * Compute a set of ids of all files under {@code roots} */ @NotNull - static VirtualFileEnumeration getFileEnumerationUnderRoots(@NotNull Collection roots) { + public static VirtualFileEnumeration getFileEnumerationUnderRoots(@NotNull Collection roots) { IntSet result = new IntOpenHashSet(); for (VirtualFile file : roots) { if (file instanceof VirtualFileWithId) { diff --git a/platform/core-impl/src/com/intellij/openapi/module/impl/ModuleScopeProviderFactory.java b/platform/core-impl/src/com/intellij/openapi/module/impl/ModuleScopeProviderFactory.java new file mode 100644 index 000000000000..85eaf30ca4c2 --- /dev/null +++ b/platform/core-impl/src/com/intellij/openapi/module/impl/ModuleScopeProviderFactory.java @@ -0,0 +1,16 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.module.impl; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import com.intellij.openapi.module.Module; + +/** + * Creates module scope provider {@link com.intellij.openapi.module.impl.ModuleScopeProvider} from module. + * The default implementation may be changed in your IDE by overriding this service. + */ +@ApiStatus.Internal +public interface ModuleScopeProviderFactory { + @NotNull + ModuleScopeProvider createProvider(@NotNull Module module); +} diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.kt b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.kt index eb938e5d88c0..f47efd16e8ec 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.kt +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.kt @@ -9,11 +9,11 @@ import com.intellij.ide.plugins.IdeaPluginDescriptorImpl import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.* import com.intellij.openapi.components.impl.stores.IComponentStore +import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.diagnostic.getOrLogException import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.module.Module -import com.intellij.openapi.module.impl.scopes.ModuleScopeProviderImpl import com.intellij.openapi.project.Project import com.intellij.openapi.project.ex.ProjectEx import com.intellij.openapi.roots.ExternalProjectSystemRegistry @@ -62,7 +62,7 @@ open class ModuleImpl @ApiStatus.Internal constructor( registerServiceInstance(serviceInterface = Module::class.java, instance = this, pluginDescriptor = fakeCorePluginDescriptor) this.project = project @Suppress("LeakingThis") - moduleScopeProvider = ModuleScopeProviderImpl(this) + moduleScopeProvider = project.service().createProvider(this) this.name = name }