From 7a7a923197904ff06f7ad18b43366516eb79f771 Mon Sep 17 00:00:00 2001 From: Marco Pennekamp Date: Thu, 14 Sep 2023 14:28:47 +0200 Subject: [PATCH] [AA] Add `getCombinedMemberScope` to `KtScopeProvider` - The function is mostly for convenience, but scope providers will be able to optimize this scope if needed (similar to how combined declared member scopes are already optimized). - `getCombinedMemberScope` will be used by `KDocReferenceResolver`. ^KT-61900 --- .../analysis/api/components/KtScopeProvider.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/components/KtScopeProvider.kt b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/components/KtScopeProvider.kt index 85636aa6bf4..7493e47d4a3 100644 --- a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/components/KtScopeProvider.kt +++ b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/components/KtScopeProvider.kt @@ -23,6 +23,13 @@ public abstract class KtScopeProvider : KtAnalysisSessionComponent() { public abstract fun getStaticMemberScope(symbol: KtSymbolWithMembers): KtScope + public open fun getCombinedMemberScope(symbol: KtSymbolWithMembers): KtScope = getCompositeScope( + listOf( + getMemberScope(symbol), + getStaticMemberScope(symbol), + ) + ) + public abstract fun getDeclaredMemberScope(classSymbol: KtSymbolWithMembers): KtScope public abstract fun getStaticDeclaredMemberScope(classSymbol: KtSymbolWithMembers): KtScope @@ -143,6 +150,12 @@ public interface KtScopeProviderMixIn : KtAnalysisSessionMixIn { public fun KtSymbolWithMembers.getStaticMemberScope(): KtScope = withValidityAssertion { analysisSession.scopeProvider.getStaticMemberScope(this) } + /** + * Returns a [KtScope] containing all members from [getMemberScope] and [getStaticMemberScope]. + */ + public fun KtSymbolWithMembers.getCombinedMemberScope(): KtScope = + withValidityAssertion { analysisSession.scopeProvider.getCombinedMemberScope(this) } + /** * Returns a [KtScope] containing the *non-static* callables and all classifiers explicitly declared in the given [KtSymbolWithMembers]. *