KtReference¶
@SubclassOptInRequired(markerClass = [KtImplementationDetail::class])
interface KtReference : PsiPolyVariantReference
Properties¶
absoluteRange¶
@get:NotNull
open val absoluteRange: @NotNull TextRange
canonicalText¶
@get:NotNull
@get:NlsSafe
abstract val canonicalText: @NotNull @NlsSafe String
element¶
isSoft¶
rangeInElement¶
@get:NotNull
abstract val rangeInElement: @NotNull TextRange
resolver¶
abstract val resolver: ResolveCache.PolyVariantResolver<KtReference>
resolvesByNames¶
abstract val resolvesByNames: Collection<Name>
Exhaustive collection of names that this reference may resolve to, or an empty collection if it cannot be predicted.
Exceptional cases
Note that there might be cases where the resolved element won't have a name from this resolvesByNames collection, so the client should handle it accordingly.
Here is a list of known cases:
-
Import aliases
-
- E.g., a function might be imported with a different name (and called via it), so the result name won't be the same
-
Implicit companion object usages
-
- If you have a companion object, and you use it implicitly via the class (e.g.,
Stringas an expression will be resolved toString.Companion)
- If you have a companion object, and you use it implicitly via the class (e.g.,
-
Constructor references
-
- Constructors don't have a name by their nature, but
resolvesByNameshas the class name instead
- Constructors don't have a name by their nature, but
Unpredictable cases
-
this/superusages -
KtNameReferenceExpressionfromKtInstanceExpressionWithLabelor KDocReference is context-sensitive and might be resolved to anonymous elements, so the result cannot be fully expressed in the terms of this API
-
Labels
-
KtLabelReferenceExpressionis context-sensitive and might be resolved to anonymous elements, so the result cannot be fully expressed in the terms of this API
-
KtConstructorDelegationReference
-
- It resolves into constructors, but the result class name cannot be predicted properly since it might be generated by compiler plugins
Return
an exhaustive collection of names that this reference may resolve to, or an empty collection if it cannot be predicted
variants¶
Functions¶
bindToElement¶
abstract fun bindToElement(p0: @NotNull PsiElement): PsiElement?
getElement¶
abstract override fun getElement(): KtElement
handleElementRename¶
abstract fun handleElementRename(p0: @NotNull String): PsiElement?
isReferenceTo¶
abstract fun isReferenceTo(p0: @NotNull PsiElement): Boolean
multiResolve¶
abstract fun multiResolve(p0: Boolean): @NotNull Array<out ResolveResult?>
resolve¶
abstract fun resolve(): @Nullable PsiElement?