KDocElement¶
interface KDocElement : PsiElement
A marker interface implemented by all elements of a KDoc comment's PSI tree.
Inheritors¶
Companion properties¶
ARRAY_FACTORY¶
val ARRAY_FACTORY: ArrayFactory<PsiElement>
EMPTY_ARRAY¶
val EMPTY_ARRAY: Array<PsiElement>
ICON_FLAG_FAST_ONLY¶
val ICON_FLAG_FAST_ONLY: Int = -2147483648
ICON_FLAG_READ_STATUS¶
val ICON_FLAG_READ_STATUS: Int = 2
ICON_FLAG_VISIBILITY¶
val ICON_FLAG_VISIBILITY: Int = 1
Properties¶
allChildren¶
val PsiElement.allChildren: PsiChildRange
The range of all direct children of this element, or an empty range if it has none.
endOffset¶
The offset just past the end of this element's text range in the file.
nextLeafs¶
The following leaf elements as a lazy sequence, nearest first.
parents¶
The ancestors of this element, from its immediate parent up to and including the containing file.
parentsWithSelf¶
val PsiElement.parentsWithSelf: Sequence<PsiElement>
This element and its ancestors, from the element itself up to and including the containing file.
prevLeafs¶
The preceding leaf elements as a lazy sequence, nearest first.
startOffset¶
val PsiElement.startOffset: Int
The offset of the start of this element's text range in the file.
startOffsetSkippingComments¶
val PsiElement.startOffsetSkippingComments: Int
The start offset of this element, skipping leading comments and the whitespace that follows them.
textRangeWithoutComments¶
val PsiElement.textRangeWithoutComments: TextRange
The text range of this element excluding any leading comments.
Functions¶
accept¶
abstract fun accept(p: @NotNull PsiElementVisitor)
acceptChildren¶
abstract fun acceptChildren(p: @NotNull PsiElementVisitor)
add¶
abstract fun add(p: @NotNull PsiElement): PsiElement
addAfter¶
abstract fun addAfter(p: @NotNull PsiElement, p1: @Nullable PsiElement): PsiElement
addBefore¶
abstract fun addBefore(p: @NotNull PsiElement, p1: @Nullable PsiElement): PsiElement
addRange¶
abstract fun addRange(p: PsiElement, p1: PsiElement): PsiElement
addRangeAfter¶
abstract fun addRangeAfter(
p: PsiElement,
p1: PsiElement,
p2: PsiElement
): PsiElement
addRangeBefore¶
abstract fun addRangeBefore(
p: @NotNull PsiElement,
p1: @NotNull PsiElement,
p2: PsiElement
): PsiElement
anyDescendantOfType¶
inline fun <reified T : PsiElement> PsiElement.anyDescendantOfType(noinline predicate: (T) -> Boolean = { true }): Boolean
Returns true if this element or any descendant of type T satisfies predicate. canGoInside controls traversal into children but does not prevent the current element from being tested.
before¶
checkAdd¶
abstract fun checkAdd(p: @NotNull PsiElement)
checkDecompiledText¶
fun PsiElement.checkDecompiledText()
Throws if this element belongs to a compiled file that is backed by a stub. Loading decompiled text is slow and should be avoided; stubs should be used instead. Called by the descendant-traversal helpers as a guard.
checkDelete¶
abstract fun checkDelete()
collectDescendantsOfType¶
Collects this element and all descendants of type T satisfying predicate into a list in post-order. canGoInside controls traversal into children but does not prevent the current element from being collected.
collectDescendantsOfTypeTo¶
inline fun <reified T : PsiElement, C : MutableCollection<T>> PsiElement.collectDescendantsOfTypeTo(
to: C,
crossinline canGoInside: (PsiElement) -> Boolean,
noinline predicate: (T) -> Boolean = { true }
): C
Adds this element and all descendants of type T satisfying predicate to to in post-order. canGoInside controls traversal into children but does not prevent the current element from being added.
copy¶
abstract fun copy(): PsiElement
delete¶
abstract fun delete()
deleteChildRange¶
abstract fun deleteChildRange(p: PsiElement, p1: PsiElement)
findDescendantOfType¶
inline fun <reified T : PsiElement> PsiElement.findDescendantOfType(noinline predicate: (T) -> Boolean = { true }): T?
Returns the first element of type T in a pre-order traversal of this element and its descendants that satisfies predicate, or null. canGoInside controls traversal into children but does not prevent the current element from being tested.
findElementAt¶
abstract fun findElementAt(p: Int): @Nullable PsiElement
findReferenceAt¶
abstract fun findReferenceAt(p: Int): @Nullable PsiReference
forEachDescendantOfType¶
inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfType(noinline action: (T) -> Unit)
inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfType(crossinline canGoInside: (PsiElement) -> Boolean, noinline action: (T) -> Unit)
Applies action to this element and every descendant of type T, in post-order. canGoInside controls whether each visited element's children are traversed; the element itself is still passed to action when it is a T, even if canGoInside returns false for it.
forEachDescendantOfTypeInPreorder¶
inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfTypeInPreorder(noinline action: (T) -> Unit)
inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfTypeInPreorder(crossinline canGoInside: (PsiElement) -> Boolean, noinline action: (T) -> Unit)
Applies action to this element and every descendant of type T, in pre-order. canGoInside controls whether each visited element's children are traversed; the element itself is still passed to action when it is a T, even if canGoInside returns false for it.
getAssignmentLhsIfUnwrappable¶
fun PsiElement.getAssignmentLhsIfUnwrappable(): PsiElement?
Returns the operand this operation applies to, but only when that operand is wrapped in parentheses, a label, or annotations; returns null otherwise.
getChildOfType¶
inline fun <reified T : PsiElement> PsiElement.getChildOfType(): T?
Returns the first direct child of type T, or null if there is none.
getChildren¶
abstract fun getChildren(): @NotNull Array<@NotNull PsiElement>
getChildrenOfType¶
inline fun <reified T : PsiElement> PsiElement.getChildrenOfType(): Array<T>
Returns the direct children of type T, or an empty array if there are none.
getContainingFile¶
abstract fun getContainingFile(): PsiFile
getContext¶
abstract fun getContext(): @Nullable PsiElement
getCopyableUserData¶
abstract fun <T> getCopyableUserData(p: @NotNull Key<T>): @Nullable T
getElementTextWithContext¶
fun PsiElement.getElementTextWithContext(): String
Returns this element's text with surrounding source context, for use in diagnostics and log messages.
getExplicitReceiverOfDotQualified¶
fun PsiElement.getExplicitReceiverOfDotQualified(): PsiElement?
Returns the source of the explicit receiver if this element is a dot-qualified expression, or null otherwise.
getFirstChild¶
abstract fun getFirstChild(): PsiElement
getIcon¶
getLanguage¶
abstract fun getLanguage(): @NotNull Language
getLastChild¶
abstract fun getLastChild(): PsiElement
getLastParentOfTypeInRow¶
inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRow(): T?
getLastParentOfTypeInRowWithSelf¶
inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRowWithSelf(): T?
Like getLastParentOfTypeInRow, but the chain may start at this element itself.
getManager¶
abstract fun getManager(): PsiManager
getNavigationElement¶
abstract fun getNavigationElement(): PsiElement
getNextSibling¶
abstract fun getNextSibling(): PsiElement
getNextSiblingIgnoringWhitespace¶
fun PsiElement.getNextSiblingIgnoringWhitespace(withItself: Boolean = false): PsiElement?
Returns the next sibling that is not whitespace, or null. Considers this element if withItself.
getNextSiblingIgnoringWhitespaceAndComments¶
fun PsiElement.getNextSiblingIgnoringWhitespaceAndComments(withItself: Boolean = false): PsiElement?
Returns the next sibling that is neither whitespace nor a comment, or null. Considers this element if withItself.
getNode¶
abstract fun getNode(): ASTNode
getNonStrictParentOfType¶
inline fun <reified T : PsiElement> PsiElement.getNonStrictParentOfType(): T?
Returns the nearest ancestor of type T including this element, or null if there is none.
fun <T : PsiElement> PsiElement.getNonStrictParentOfType(parentClass: Class<T>): T?
Returns the nearest ancestor of type T (including this element), or null if there is none.
getOriginalElement¶
abstract fun getOriginalElement(): PsiElement
getOutermostParentContainedIn¶
tailrec fun PsiElement.getOutermostParentContainedIn(container: PsiElement): PsiElement?
Returns the outermost element on the path from this element that is still strictly contained in container, or null.
getOwnDeclarations¶
open fun getOwnDeclarations(): @NotNull Collection<out @NotNull PsiSymbolDeclaration>
getOwnReferences¶
open fun getOwnReferences(): @NotNull Collection<out @NotNull PsiSymbolReference>
getParent¶
abstract fun getParent(): PsiElement
getParentOfType¶
inline fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean): T?
inline fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean, vararg stopAt: Class<out PsiElement>): T?
getParentOfTypeAndBranch¶
inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranch(strict: Boolean = false, noinline branch: T.() -> PsiElement?): T?
getParentOfTypeAndBranches¶
getParentOfTypes¶
Returns the nearest ancestor that is an instance of one of parentClasses, or null if there is none. When strict is false, this element itself is also considered.
getParentOfTypes2¶
inline fun <reified T : PsiElement, reified V : PsiElement> PsiElement.getParentOfTypes2(): PsiElement?
getParentOfTypes3¶
inline fun <reified T : PsiElement, reified V : PsiElement, reified U : PsiElement> PsiElement.getParentOfTypes3(): PsiElement?
getParentOfTypesAndPredicate¶
Returns the nearest ancestor that is an instance of one of parentClasses and satisfies predicate, or null. When parentClasses is empty, any type matches. When strict is false, this element itself is also considered.
getPrevSibling¶
abstract fun getPrevSibling(): PsiElement
getPrevSiblingIgnoringWhitespace¶
fun PsiElement.getPrevSiblingIgnoringWhitespace(withItself: Boolean = false): PsiElement?
Returns the previous sibling that is not whitespace, or null. Considers this element if withItself.
getPrevSiblingIgnoringWhitespaceAndComments¶
fun PsiElement.getPrevSiblingIgnoringWhitespaceAndComments(withItself: Boolean = false): PsiElement?
Returns the previous sibling that is neither whitespace nor a comment, or null. Considers this element if withItself.
getProject¶
abstract fun getProject(): @NotNull Project
getReference¶
abstract fun getReference(): @Nullable PsiReference
getReferences¶
abstract fun getReferences(): @NotNull Array<PsiReference>
getResolveScope¶
abstract fun getResolveScope(): @NotNull GlobalSearchScope
getStartOffsetIn¶
fun PsiElement.getStartOffsetIn(ancestor: PsiElement): Int
Returns the offset of this element relative to the start of ancestor (which must be an ancestor of this element).
getStartOffsetInParent¶
abstract fun getStartOffsetInParent(): Int
getStrictParentOfType¶
inline fun <reified T : PsiElement> PsiElement.getStrictParentOfType(): T?
Returns the nearest strict ancestor of type T, or null if there is none.
getText¶
getTextLength¶
abstract fun getTextLength(): Int
getTextOffset¶
abstract fun getTextOffset(): Int
getTextRange¶
abstract fun getTextRange(): TextRange
getTextRangeInParent¶
open fun getTextRangeInParent(): @NotNull TextRange
getTextWithLocation¶
fun PsiElement.getTextWithLocation(): String
Returns this element's text together with its source location, for use in diagnostics and log messages.
getTopmostParentOfType¶
inline fun <reified T : PsiElement> PsiElement.getTopmostParentOfType(): T?
Returns the outermost ancestor of type T including this element, or null if there is none.
getUserData¶
abstract fun <T> getUserData(p: @NotNull Key<T>): @Nullable T
getUseScope¶
abstract fun getUseScope(): @NotNull SearchScope
isAncestor¶
fun PsiElement?.isAncestor(element: PsiElement, strict: Boolean = false): Boolean
isEquivalentTo¶
abstract fun isEquivalentTo(p: PsiElement): Boolean
isExtensionDeclaration¶
fun PsiElement.isExtensionDeclaration(): Boolean
Returns true if this element is an extension function or property (that is, it declares a receiver).
isFunctionalExpression¶
fun PsiElement.isFunctionalExpression(): Boolean
Returns true if this element is an anonymous function, such as the fun expression in val predicate = fun(x: Int): Boolean = x > 0.
isInsideOf¶
fun PsiElement.isInsideOf(elements: Iterable<PsiElement>): Boolean
Returns true if this element lies within, or is equal to, any of the given elements.
isPhysical¶
abstract fun isPhysical(): Boolean
isTopLevelKtOrJavaMember¶
fun PsiElement.isTopLevelKtOrJavaMember(): Boolean
Returns true if this element is a top-level member of a Kotlin file or a top-level Java class.
isValid¶
isWritable¶
abstract fun isWritable(): Boolean
nextLeaf¶
Returns the next leaf element in the tree, or null if there is none. Empty leaves are skipped if skipEmptyElements.
Returns the nearest following leaf that satisfies filter, or null if there is none.
parameterIndex¶
fun PsiElement.parameterIndex(): Int
Returns the index of this parameter within its own parameter list (Kotlin or Java), or -1 if it is not a parameter.
prevLeaf¶
Returns the previous leaf element in the tree, or null if there is none. Empty leaves are skipped if skipEmptyElements.
Returns the nearest preceding leaf that satisfies filter, or null if there is none.
processDeclarations¶
abstract fun processDeclarations(
p: @NotNull PsiScopeProcessor,
p1: @NotNull ResolveState,
p2: @Nullable PsiElement,
p3: @NotNull PsiElement
): Boolean
putCopyableUserData¶
abstract fun <T> putCopyableUserData(p: @NotNull Key<T>, p1: @Nullable T)
putUserData¶
abstract fun <T> putUserData(p: @NotNull Key<T>, p1: @Nullable T)
replace¶
abstract fun replace(p: @NotNull PsiElement): PsiElement
siblings¶
Returns the siblings of this element as a lazy sequence, going forward (or backward) and optionally including the element itself (withItself).
startsWithComment¶
fun PsiElement.startsWithComment(): Boolean
Returns true if this element's first child is a comment.
textContains¶
abstract fun textContains(p: Char): Boolean
textMatches¶
abstract fun textMatches(p: @NotNull @NonNls CharSequence): Boolean
textToCharArray¶
abstract fun textToCharArray(): @NotNull Array<Char>
toString¶
unwrapParenthesesLabelsAndAnnotations¶
fun PsiElement?.unwrapParenthesesLabelsAndAnnotations(): PsiElement?
Recursively unwraps this element while it is a parenthesized, labeled, or annotated expression, returning the innermost base element. A non-wrapper element is returned unchanged.
unwrapParenthesesLabelsAndAnnotationsDeeply¶
fun PsiElement.unwrapParenthesesLabelsAndAnnotationsDeeply(): PsiElement
Walks up through immediately enclosing parentheses, labels, and annotations, returning the first parent outside that wrapper chain.