[Analysis API] add KDocs for KtTypeScopeProvider

This commit is contained in:
Ilya Kirillov
2022-06-13 16:50:35 +02:00
parent d5113892df
commit 3ea2232591
2 changed files with 27 additions and 3 deletions
@@ -65,6 +65,26 @@ public interface KtScopeProviderMixIn : KtAnalysisSessionMixIn {
public fun List<KtScope>.asCompositeScope(): KtScope =
withValidityAssertion { analysisSession.scopeProvider.getCompositeScope(this) }
/**
* Return a [KtTypeScope] for a given [KtType].
* The type scope will include all members which are declared and callable on a given type.
*
* Comparing to the [KtScope], in the [KtTypeScope] all use-site type parameters are substituted.
*
* Consider the following code
* ```
* fun foo(list: List<String>) {
* list // get KtTypeScope for it
* }
*```
*
* Inside the `LIST_KT_ELEMENT.getKtType().getTypeScope()` would contain the `get(i: Int): String` method with substituted type `T = String`
*
* @return type scope for the given type if given `KtType` is not error type, `null` otherwise.
*
* @see KtTypeScope
* @see KtTypeProviderMixIn.getKtType
*/
public fun KtType.getTypeScope(): KtTypeScope? =
withValidityAssertion { analysisSession.scopeProvider.getTypeScope(this) }
@@ -5,16 +5,20 @@
package org.jetbrains.kotlin.analysis.api.scopes
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtClassifierSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
import org.jetbrains.kotlin.analysis.api.signatures.KtCallableSignature
/**
* A scope inside which use-site type-parameters of callable declarations may be substituted. Such declarations are represented as [KtCallableSignature].
*
* @see org.jetbrains.kotlin.analysis.api.components.KtScopeProviderMixIn.getTypeScope
* @see KtCallableSignature
*/
public interface KtTypeScope : KtScopeLike {
/**
* Return a sequence of [KtCallableSymbol] which current scope contain if declaration name matches [nameFilter]
* Return a sequence of [KtCallableSignature] which current scope contain if declaration name matches [nameFilter].
*/
public fun getCallableSignatures(nameFilter: KtScopeNameFilter = { true }): Sequence<KtCallableSignature<*>>