KaScopeProvider¶
@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaScopeProvider : KaSessionComponent
Inheritors¶
Properties¶
combinedDeclaredMemberScope¶
abstract val KaDeclarationContainerSymbol.combinedDeclaredMemberScope: KaScope
A KaScope containing all members explicitly declared in the given KaDeclarationContainerSymbol.
In contrast to declaredMemberScope and staticDeclaredMemberScope, this scope contains both static and non-static members.
combinedMemberScope¶
A KaScope containing all members from memberScope and staticMemberScope.
declarationScope¶
abstract val KaTypeScope.declarationScope: KaScope
declaredMemberScope¶
abstract val KaDeclarationContainerSymbol.declaredMemberScope: KaScope
A KaScope containing the non-static callables (functions, properties, and constructors) and inner classes explicitly declared in the given KaDeclarationContainerSymbol.
The declared member scope does not contain classifiers (including the companion object) except for inner classes. To retrieve the classifiers declared in this KaDeclarationContainerSymbol, please use the static declared member scope provided by staticDeclaredMemberScope.
See also
delegatedMemberScope¶
abstract val KaDeclarationContainerSymbol.delegatedMemberScope: KaScope
A KaScope containing synthetic callables (functions and properties) created by interface delegation.
Example
interface I {
val foo: Int get() = 2
fun bar(): String
}
class A(
private val p: I
) : I by p {
val regularProperty: Int = 5
}
The delegated member scope for A has the following entries:
regularProperty is not contained in the delegated member scope because it is not a delegated property.
fileScope¶
abstract val KaFileSymbol.fileScope: KaScope
A KaScope containing the top-level declarations (such as classes, functions and properties) in the given KaFileSymbol.
importingScopeContext¶
abstract val KtFile.importingScopeContext: KaScopeContext
A KaScopeContext formed from all imports in the KtFile.
By default, the scope context also includes default importing scopes, which can be filtered by KaScopeKind.
memberScope¶
abstract val KaDeclarationContainerSymbol.memberScope: KaScope
A KaScope containing non-static callable members (functions, properties, and constructors) and all classifier members (classes and objects) of the given KaDeclarationContainerSymbol. The scope includes members inherited from the symbol's supertypes, in addition to members which are declared explicitly inside the symbol's body.
The member scope doesn't include synthetic Java properties. For a scope which contains synthetic properties, please refer to syntheticJavaPropertiesScope.
See also
packageScope¶
abstract val KaPackageSymbol.packageScope: KaScope
A KaScope containing all members of the package represented by the given KaPackageSymbol, not including members of subpackages.
scope¶
abstract val KaType.scope: KaTypeScope?
A KaTypeScope for the given KaType, or null if the type is erroneous. The scope includes all members which are callable on a given type. It also includes synthetic Java properties.
Comparing to KaScope, the KaTypeScope contains members whose use-site type parameters have been substituted.
Example
We can get a KaTypeScope for the expression type of list. This scope contains a get(index: Int): String function, where the return type E from List.get is substituted with the type argument String.
See also
staticDeclaredMemberScope¶
abstract val KaDeclarationContainerSymbol.staticDeclaredMemberScope: KaScope
A KaScope containing the static callables (functions and properties) and all classifiers (classes and objects) explicitly declared in the given KaDeclarationContainerSymbol.
It is worth noting that, while Java classes may contain declarations of static callables freely, in Kotlin only enum classes define static callables. Hence, for non-enum Kotlin classes, it is not expected that the static declared member scope will contain any callables.
See also
staticMemberScope¶
abstract val KaDeclarationContainerSymbol.staticMemberScope: KaScope
A KaScope containing the static members of the given KaDeclarationContainerSymbol.
The behavior of the scope differs based on whether the given KaDeclarationContainerSymbol is a Kotlin or Java class:
-
Kotlin class: The scope contains static callables (functions and properties) and classifiers (classes and objects) declared directly in the
KaDeclarationContainerSymbol. Hence, the static member scope for Kotlin classes is equivalent tostaticDeclaredMemberScope. -
Java class: The scope contains static callables (functions and properties) declared in the
KaDeclarationContainerSymbolor any of its superclasses (excluding static callables from super-interfaces), and classes declared directly in theKaDeclarationContainerSymbol. This follows Kotlin's rules about static inheritance in Java classes, where static callables are propagated from superclasses, but nested classes are not.
Kotlin Example
abstract class A {
class C1
inner class D1
object O1
// There is no way to declare a static callable in an abstract class, as only enum classes define additional static callables.
}
class B : A() {
class C2
inner class D2
object O2
companion object {
val baz: String = ""
}
}
The static member scope of B contains the following symbols:
Java Example
// SuperInterface.java
public interface SuperInterface {
public static void fromSuperInterface() { }
}
// SuperClass.java
public abstract class SuperClass implements SuperInterface {
static class NestedSuperClass { }
class InnerSuperClass { }
public static void fromSuperClass() { }
}
// FILE: JavaClass.java
public class JavaClass extends SuperClass {
static class NestedClass { }
class InnerClass { }
public static void fromJavaClass() { }
}
The static member scope of JavaClass contains the following symbols:
public static void fromSuperClass()
public static void fromJavaClass()
static class NestedClass
class InnerClass
See also
syntheticJavaPropertiesScope¶
abstract val KaType.syntheticJavaPropertiesScope: KaTypeScope?
A KaTypeScope containing the synthetic Java properties created for a given KaType.
token¶
abstract val token: KaLifetimeToken
The KaLifetimeToken which determines the lifetime of the lifetime owner.
Functions¶
asCompositeScope¶
abstract fun List<KaScope>.asCompositeScope(): KaScope
assertIsValidAndAccessible¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
compositeScope¶
open fun KaScopeContext.compositeScope(filter: (KaScopeKind) -> Boolean = { true }): KaScope
isValid¶
fun KaLifetimeOwner.isValid(): Boolean
Whether the lifetime owner is still valid, i.e. we are still in the scope of the lifetime owner's regular lifetime.
scopeContext¶
abstract fun KtFile.scopeContext(position: KtElement): KaScopeContext
withValidityAssertion¶
inline fun <R> KaLifetimeOwner.withValidityAssertion(action: () -> R): R
Executes action only if the KaLifetimeOwner is still valid and accessible. Otherwise, throws a validity exception based on the concrete violation.