[Analysis API] add KtTypeScope.getCallableSignatures/getClassifierSymbols overloads which accept a candidate name set
This is needed for the cases when a candidate name set is known to avoid retrieving a set with all possible names when processing the scope. Similar to KtScope. ^KT-58653
This commit is contained in:
committed by
Space Team
parent
ee1fd9f6e9
commit
f8ddf204e2
+8
@@ -41,10 +41,18 @@ internal open class KtFirDelegatingTypeScope(
|
||||
firScope.getCallableSignatures(getPossibleCallableNames().filter(nameFilter), builder)
|
||||
}
|
||||
|
||||
override fun getCallableSignatures(names: Collection<Name>): Sequence<KtCallableSignature<*>> = withValidityAssertion {
|
||||
firScope.getCallableSignatures(names, builder)
|
||||
}
|
||||
|
||||
override fun getClassifierSymbols(nameFilter: KtScopeNameFilter): Sequence<KtClassifierSymbol> = withValidityAssertion {
|
||||
firScope.getClassifierSymbols(getPossibleClassifierNames().filter(nameFilter), builder)
|
||||
}
|
||||
|
||||
override fun getClassifierSymbols(names: Collection<Name>): Sequence<KtClassifierSymbol> = withValidityAssertion {
|
||||
firScope.getClassifierSymbols(names, builder)
|
||||
}
|
||||
|
||||
override fun getConstructors(): Sequence<KtConstructorSymbol> = withValidityAssertion {
|
||||
firScope.getConstructors(builder)
|
||||
}
|
||||
|
||||
+14
-1
@@ -11,7 +11,8 @@ import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScopeNameFilter
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KtTypeScope
|
||||
import org.jetbrains.kotlin.analysis.api.signatures.KtCallableSignature
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassifierSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
@KtAnalysisApiInternals
|
||||
@@ -44,12 +45,24 @@ class KtCompositeTypeScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCallableSignatures(names: Collection<Name>): Sequence<KtCallableSignature<*>> = withValidityAssertion {
|
||||
sequence {
|
||||
subScopes.forEach { yieldAll(it.getCallableSignatures(names)) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClassifierSymbols(nameFilter: KtScopeNameFilter): Sequence<KtClassifierSymbol> = withValidityAssertion {
|
||||
sequence {
|
||||
subScopes.forEach { yieldAll(it.getClassifierSymbols(nameFilter)) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClassifierSymbols(names: Collection<Name>): Sequence<KtClassifierSymbol> = withValidityAssertion {
|
||||
sequence {
|
||||
subScopes.forEach { yieldAll(it.getClassifierSymbols(names)) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getConstructors(): Sequence<KtConstructorSymbol> = withValidityAssertion {
|
||||
sequence {
|
||||
subScopes.forEach { yieldAll(it.getConstructors()) }
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.scopes
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
||||
import org.jetbrains.kotlin.analysis.api.signatures.KtCallableSignature
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassifierSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.signatures.KtCallableSignature
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
/**
|
||||
* A scope inside which use-site type-parameters of callable declarations may be substituted. Such declarations are represented as [KtCallableSignature].
|
||||
@@ -22,12 +24,49 @@ public interface KtTypeScope : KtScopeLike {
|
||||
*/
|
||||
public fun getCallableSignatures(nameFilter: KtScopeNameFilter = { true }): Sequence<KtCallableSignature<*>>
|
||||
|
||||
/**
|
||||
* Return a sequence of [KtCallableSignature] which current scope contain if declaration, if declaration name present in [names]
|
||||
*
|
||||
* This implementation is more optimal than the one with `nameFilter` and should be used when the candidate name set is known.
|
||||
*/
|
||||
public fun getCallableSignatures(names: Collection<Name>): Sequence<KtCallableSignature<*>>
|
||||
|
||||
/**
|
||||
* Return a sequence of [KtCallableSignature] which current scope contain if declaration, if declaration name present in [names]
|
||||
*
|
||||
* @see getCallableSignatures
|
||||
*/
|
||||
public fun getCallableSignatures(vararg names: Name): Sequence<KtCallableSignature<*>> = withValidityAssertion {
|
||||
getCallableSignatures(names.toList())
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a sequence of [KtClassifierSymbol] which current scope contain if classifier name matches [nameFilter]. The sequence includes:
|
||||
* nested classes, inner classes, nested type aliases for the class scope, and top-level classes and top-level type aliases for file scope.
|
||||
*
|
||||
* This function needs to retrieve a set of all possible names before processing the scope.
|
||||
* The overload with `names: Collection<Name>` should be used when the candidate name set is known.
|
||||
*/
|
||||
public fun getClassifierSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtClassifierSymbol>
|
||||
|
||||
/**
|
||||
* Return a sequence of [KtClassifierSymbol] which current scope contains, if classifier name present in [names].
|
||||
*
|
||||
* The sequence includes: nested classes, inner classes, nested type aliases for the class scope,
|
||||
* and top-level classes and top-level type aliases for file scope.
|
||||
*
|
||||
* This implementation is more optimal than the one with `nameFilter` and should be used when the candidate name set is known.
|
||||
*/
|
||||
public fun getClassifierSymbols(names: Collection<Name>): Sequence<KtClassifierSymbol>
|
||||
|
||||
/**
|
||||
* Return a sequence of [KtClassifierSymbol] which current scope contains, if classifier name present in [names].
|
||||
*
|
||||
* @see getClassifierSymbols
|
||||
*/
|
||||
public fun getClassifierSymbols(vararg names: Name): Sequence<KtClassifierSymbol> =
|
||||
getClassifierSymbols(names.toList())
|
||||
|
||||
/**
|
||||
* Return a sequence of [KtConstructorSymbol] which current scope contain
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user