org.jetbrains.kotlin.psi.psiUtil¶
Types¶
KtStringTemplateExpressionManipulator¶
class KtStringTemplateExpressionManipulator : AbstractElementManipulator<KtStringTemplateExpression>
The ElementManipulator of KtStringTemplateExpression, which edits the content of a string literal, e.g., when a language fragment injected into the string is edited or a reference contributed to the string is renamed.
PsiChildRange¶
data class PsiChildRange(val first: PsiElement?, val last: PsiElement?) : Sequence<PsiElement>
Properties¶
allChildren¶
val PsiElement.allChildren: PsiChildRange
The range of all direct children of this element, or an empty range if it has none.
argumentIndex¶
The index of this argument within its enclosing value argument list.
containingClassId¶
val KtDeclaration.containingClassId: ClassId?
The containing ClassId for this declaration. REPL KtScripts are supported.
containingClassOrObject¶
The containing class for the body.
The containing class for the companion block.
The class or object that declares this declaration as a member (including constructors and nested classes), or null if it is not a class member — for example, a member function's parameter or local, or a property accessor.
containingClassOrScript¶
The containing class or script for a declaration.
containingScript¶
The containing script for the block expression.
The containing script for top-level declarations.
endOffset¶
The offset just past the end of this element's text range in the file.
isCompanion¶
Whether the callable is a companion extension or comes from a companion block.
isFromCompanionBlock¶
Whether this declaration is declared inside a companion object block.
isPrivateNestedClassOrObject¶
true if this is a private nested (non-top-level) class or object.
isPublic¶
true if this declaration is effectively public (no visibility modifier or an explicit public), and not local.
isUnderscoreInBackticks¶
true if this reference is the backtick-escaped underscore identifier `_` (distinct from the plain _ placeholder).
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.
plainContent¶
The source text between the string delimiters, including any escape or interpolation syntax.
prevLeafs¶
The preceding leaf elements as a lazy sequence, nearest first.
pureEndOffset¶
The end offset of this element's source.
pureStartOffset¶
The start offset of this element's source, excluding any leading comments.
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.
UNWRAPPABLE_TOKEN_TYPES¶
val UNWRAPPABLE_TOKEN_TYPES: Set<IElementType>
See org.jetbrains.kotlin.fir.builder.AbstractRawFirBuilder.unwrap
Functions¶
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.
asAssignment¶
Returns this expression as a KtBinaryExpression if it is an assignment, or null otherwise.
before¶
blockExpressionsOrSingle¶
Returns the statements of this element if it is a block, otherwise a single-element sequence of this element.
canPlaceAfterSimpleNameEntry¶
fun canPlaceAfterSimpleNameEntry(element: PsiElement?): Boolean
Returns true if placing text after a $name simple-name template entry would not accidentally extend the name, that is, element does not begin with an identifier character.
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.
children¶
The direct child nodes of this AST node, as a lazy sequence.
closestPsiElement¶
fun ASTNode.closestPsiElement(): PsiElement?
Returns the nearest PSI element for this node, walking up to a parent node if this node has no PSI of its own.
collectAnnotationEntriesFromStubOrPsi¶
Collects the annotation entries of this container, reading from the stub when available and falling back to the PSI.
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.
containingClass¶
fun KtElement.containingClass(): KtClass?
Returns the nearest enclosing KtClass, or null if there is none.
contains¶
Returns true if element lies within this search scope.
containsInside¶
fun TextRange.containsInside(offset: Int): Boolean
Returns true if offset lies strictly inside this range (excluding both endpoints).
contentRange¶
Returns the range of direct PSI children between this block's braces after excluding outer whitespace. The range may contain comments and other non-statement elements. Returns an empty range if either brace is missing or no non-whitespace content remains.
effectiveDeclarations¶
Returns the body declarations of this class or object in source order, followed by the class's primary-constructor val/var property parameters in parameter order.
elementsInRange¶
fun PsiFile.elementsInRange(range: TextRange): List<PsiElement>
Returns the top-level elements that together cover the given range within this file.
findAssignment¶
tailrec fun findAssignment(element: PsiElement?): KtBinaryExpression?
Walks up from element through qualified/simple-name expressions to find a plain = assignment whose LHS it is.
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.
findFunctionByName¶
fun KtClassOrObject.findFunctionByName(name: String): KtNamedDeclaration?
Returns the member function with the given name, or null if there is none.
findLabelAndCall¶
fun KtFunctionLiteral.findLabelAndCall(): Pair<Name?, KtCallExpression?>
Returns the label (explicit or the enclosing call's name) and the call that this lambda is passed to, as a pair. Either component may be null if it cannot be determined.
findPropertyByName¶
fun KtClassOrObject.findPropertyByName(name: String): KtNamedDeclaration?
Returns the member property (or primary-constructor property parameter) with the given name, or null.
flatMapDescendantsOfTypeVisitor¶
inline fun <reified T : KtElement, R> flatMapDescendantsOfTypeVisitor(accumulator: MutableCollection<R>, noinline map: (T) -> Collection<R>): KtVisitorVoid
Returns a recursive visitor that maps each visited element of type T, including the element passed to accept, and adds all results to accumulator in DFS-exit order.
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.
forEachDescendantOfTypeVisitor¶
inline fun <reified T : KtElement> forEachDescendantOfTypeVisitor(noinline block: (T) -> Unit): KtVisitorVoid
getAnnotationEntries¶
Returns the annotation entries applied to this expression through an enclosing annotated (or labeled) expression, or an empty list if there are none.
getAssignmentByLHS¶
Returns the assignment in which this expression is the left-hand side, or null if it is not assigned to.
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.
getBinaryWithTypeParent¶
Returns the as/as? expression whose left-hand side is a call with this expression as its direct child, normally its callee. The call may be the selector of a qualified expression, and the call or qualified expression may be parenthesized. Returns null otherwise.
getCallNameExpression¶
Returns the simple-name reference of this call's callee (its function or constructor name), or null.
getChildOfType¶
inline fun <reified T : PsiElement> PsiElement.getChildOfType(): T?
Returns the first direct child of type T, or null if there is none.
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.
getContainingKtFile¶
fun LazyParseablePsiElement.getContainingKtFile(): KtFile
Returns the KtFile containing this element.
getContentRange¶
fun KtStringTemplateExpression.getContentRange(): TextRange
Returns the text range of the string content, excluding the interpolation prefix and the opening/closing quotes.
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.
getFileOrScriptDeclarations¶
Returns the top-level declarations of this file, taking them from the script if the file is a script.
getIfChildIsInBranch¶
fun <T : PsiElement> T.getIfChildIsInBranch(element: PsiElement, branch: T.() -> PsiElement?): T?
getIfChildIsInBranches¶
getImportedSimpleNameByImportAlias¶
fun getImportedSimpleNameByImportAlias(file: KtFile, aliasName: String): String?
getLabeledParent¶
fun KtExpression.getLabeledParent(labelName: String): KtLabeledExpression?
Returns the nearest enclosing labeled expression with the given labelName, or null if there is none.
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.
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.
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.
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.
getOutermostParenthesizerOrThis¶
Returns the outermost expression that wraps this one only through parentheses, labels, or annotations, or this expression itself.
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.
getPossiblyQualifiedCallExpression¶
Returns the call expression this expression represents: the selector's call for a qualified expression, or this expression if it is itself a call. Returns null if there is no call.
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.
getQualifiedElement¶
Returns the enclosing qualified element for this name: a KtQualifiedExpression, a KtUserType, or this expression itself if there is no such qualifier.
getQualifiedElementOrCallableRef¶
Like getQualifiedElement, but also returns the enclosing KtCallableReferenceExpression when this name is its callable reference.
getQualifiedElementSelector¶
Returns the rightmost selector of this qualified element, or null if there is no such selector.
getQualifiedExpressionForReceiver¶
Returns the qualified expression in which this expression is the receiver, or null if it is not a receiver.
getQualifiedExpressionForReceiverOrThis¶
Returns the qualified expression in which this expression is the receiver, or this expression itself otherwise.
getQualifiedExpressionForSelector¶
Returns the qualified expression in which this element is the selector, or null if it is not a selector.
getQualifiedExpressionForSelectorOrThis¶
Returns the qualified expression in which this expression is the selector, or this expression itself otherwise.
getReceiverExpression¶
Returns the receiver this name is applied to, considering qualified expressions, binary/unary operators, and qualified user types, or null if this name has no receiver.
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).
getStrictParentOfType¶
inline fun <reified T : PsiElement> PsiElement.getStrictParentOfType(): T?
Returns the nearest strict ancestor of type T, or null if there is none.
getSuperNames¶
fun StubBasedPsiElementBase<out KotlinClassOrObjectStub<out KtClassOrObject>>.getSuperNames(): List<String>
Returns the unqualified names indexed as this class's superclass names. For names that might be imported through an alias, this includes both the original and aliased names; reference resolution during inheritor search disambiguates them.
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.
getTopmostParentQualifiedExpressionForSelector¶
Returns the outermost qualified expression in which this name is (transitively) the selector, or null.
getTrailingCommaByClosingElement¶
fun getTrailingCommaByClosingElement(closingElement: PsiElement?): PsiElement?
Returns the trailing comma immediately before closingElement (a closing bracket/parenthesis), or null.
getTrailingCommaByElementsList¶
fun getTrailingCommaByElementsList(elementList: PsiElement?): PsiElement?
Returns the trailing comma at the end of elementList (skipping a trailing comment), or null if there is none.
getValueParameterList¶
Returns the value parameter list of this declaration (the primary constructor's for a class), or null.
getValueParameters¶
Returns the value parameters of this declaration (constructor value parameters for a class), or an empty list.
hasActualModifier¶
Returns true if this modifier list contains the actual modifier.
Returns true if this declaration has the actual modifier.
hasBody¶
fun KtDeclaration.hasBody(): Boolean
Returns true if this declaration is a function or property that defines a body.
hasExpectModifier¶
Returns true if this modifier list contains the expect modifier.
Returns true if this declaration has the expect modifier.
hasExternalModifier¶
Returns true if this declaration has the external modifier.
hasFunModifier¶
fun KtModifierList.hasFunModifier(): Boolean
Returns true if this modifier list contains the fun modifier (a functional interface).
hasInnerModifier¶
Returns true if this declaration has the inner modifier.
hasSuspendModifier¶
Returns true if this modifier list contains the suspend modifier.
hasValueModifier¶
Returns true if this modifier list contains the value modifier (a value class).
inferClassIdByPsi¶
fun KtConstantExpression.inferClassIdByPsi(): ClassId?
A best-effort way to get the ClassId of this expression's type without semantic resolution.
isAbstract¶
fun KtClass.isAbstract(): Boolean
Returns true if this class is abstract, that is, it is an interface or has the abstract modifier.
isActualDeclaration¶
Returns true if this declaration is actual: either it has an explicit actual modifier, or it is a constructor of an actual annotation, value, or inline class.
isAncestor¶
fun PsiElement?.isAncestor(element: PsiElement, strict: Boolean = false): Boolean
isCallee¶
Returns true if this expression can be the callee of a call with the same name.
isContextualDeclaration¶
Returns true if this callable, class, or object declares at least one legacy context receiver. Named context parameters are ignored.
isContractDescriptionCallPsiCheck¶
Best-effort PSI check for whether this expression is a contract { ... } (or kotlin.contracts.contract { ... }) call.
Best-effort PSI check for whether this qualified expression is a kotlin.contracts.contract { ... } call.
isContractPresentPsiCheck¶
fun KtNamedFunction.isContractPresentPsiCheck(isAllowedOnMembers: Boolean): Boolean
Best-effort PSI check for whether this function's body begins with a contract { ... } call, taking into account whether contracts are allowed on member functions via isAllowedOnMembers. false is definitive; true is not a guarantee.
isDotReceiver¶
fun KtExpression.isDotReceiver(): Boolean
Returns true if this expression is the receiver of an enclosing dot-qualified expression.
isDotSelector¶
fun KtExpression.isDotSelector(): Boolean
Returns true if this expression is the selector of an enclosing dot-qualified expression.
isDoubleColonReceiver¶
fun isDoubleColonReceiver(expression: KtExpression): Boolean
Returns true if expression is the receiver of an enclosing :: (callable reference or class literal) expression.
isExpectDeclaration¶
Returns true if this declaration is expect, either directly (via the modifier) or by being contained in an expect declaration.
isExtensionDeclaration¶
fun PsiElement.isExtensionDeclaration(): Boolean
Returns true if this element is an extension function or property (that is, it declares a receiver).
isFirstStatement¶
fun KtElement.isFirstStatement(): Boolean
Returns true if this element is the first statement of its enclosing block.
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.
isIdentifier¶
fun String?.isIdentifier(): Boolean
Checks if this string is a valid Kotlin identifier.
isImportDirectiveExpression¶
Returns true if this name is part of an import directive.
isInImportDirective¶
Returns true if this expression appears inside an import directive.
isInsideOf¶
fun PsiElement.isInsideOf(elements: Iterable<PsiElement>): Boolean
Returns true if this element lies within, or is equal to, any of the given elements.
isLambdaOutsideParentheses¶
Returns true if this expression is a trailing lambda argument written outside the call parentheses.
isLegacyContractPresentPsiCheck¶
Whether the declaration may have a legacy contract (a contract defined inside the body).
isNull¶
fun KtExpression.isNull(): Boolean
Returns true if this expression is the null literal. Smart-casts the receiver to KtConstantExpression on true.
isObjectLiteral¶
Returns true if this is the body of an object literal (object : Foo { ... }).
isPackageDirectiveExpression¶
Returns true if this name is part of a package directive.
isPlain¶
Returns true if this string consists only of literal text, with no interpolation or escape sequences.
isPlainWithEscapes¶
Returns true if this string consists only of literal text and escape sequences, with no interpolation.
isPrivate¶
fun KtModifierListOwner.isPrivate(): Boolean
Returns true if this declaration has the private modifier.
isPropertyParameter¶
Returns true if this parameter is a primary-constructor val/var property parameter.
isProtected¶
Returns true if this declaration has the protected modifier.
isSingleQuoted¶
Returns true if this uses the regular one-character quote delimiter (") rather than a triple-quote delimiter (""").
isTopLevelInFileOrScript¶
fun isTopLevelInFileOrScript(element: PsiElement): Boolean
Returns true if element is a top-level element of a file or a top-level statement of a script.
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.
isTypeConstructorReference¶
fun isTypeConstructorReference(e: PsiElement): Boolean
Returns true if e is the reference expression naming the classifier in a user type.
lastBlockStatementOrThis¶
Returns the last statement if this expression is a block, otherwise this expression itself.
leaves¶
The leaf nodes following (or preceding, if not forward) this AST node, as a lazy sequence.
modalityModifier¶
fun KtDeclaration.modalityModifier(): PsiElement?
Returns the modality modifier token (abstract/open/final/sealed), or null if none is present.
modalityModifierType¶
Returns the type of this declaration's modality modifier, or null if none is present.
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.
nextSiblingOfSameType¶
inline fun <reified T : PsiElement> T.nextSiblingOfSameType(): @Nullable T?
Returns the next sibling of the same type T, or null if there is none.
nonStaticOuterClasses¶
Returns the enclosing classes that this element can access an outer instance of, from innermost to outermost.
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.
parents¶
The ancestor nodes of this AST node, from its parent upward, as a lazy sequence.
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.
prevSiblingOfSameType¶
inline fun <reified T : PsiElement> T.prevSiblingOfSameType(): @Nullable T?
Returns the previous sibling of the same type T, or null if there is none.
quoteIfNeeded¶
fun String.quoteIfNeeded(): String
Returns this string as-is if it is a valid identifier, otherwise wrapped in backticks.
referenceExpression¶
Returns the reference expression of this expression (the callee for a call), or null if it is not a reference.
safeFqNameForLazyResolve¶
fun KtNamedDeclaration.safeFqNameForLazyResolve(): FqName?
Returns this declaration's fully qualified name using the safe name for lazy resolution, or null if unavailable.
safeNameForLazyResolve¶
fun Name?.safeNameForLazyResolve(): Name
Returns this name, or the "no name provided" special name if it is null or special.
fun KtNamedDeclaration.safeNameForLazyResolve(): Name
Returns this declaration's name, substituting the "no name provided" special name for a missing or special name.
siblings¶
The sibling nodes of this AST node, going forward (or backward), as a lazy sequence.
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.
topParenthesizedParentOrMe¶
Returns the outermost enclosing expression that this expression is wrapped in only through parentheses, or this expression itself.
tryFlattenStringConcatenationArguments¶
Returns the string-template arguments of this expression if it is a string-literal concatenation; otherwise, returns null.
tryFlattenStringConcatenationDescendants¶
fun KtBinaryExpression.tryFlattenStringConcatenationDescendants(): List<PsiElement>?
Returns all descendants of this expression in flattened form if it is a string-literal concatenation; otherwise, returns null.
unwrapNullability¶
tailrec fun KtTypeElement.unwrapNullability(): KtTypeElement?
Returns this type after stripping all outer KtNullableType layers. Returns null only if a nullable-type node is malformed and has no inner type.
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.
visibilityModifier¶
fun KtModifierList.visibilityModifier(): PsiElement?
Returns the visibility modifier token (public/private/protected/internal), or null if none is present.
fun KtModifierListOwner.visibilityModifier(): PsiElement?
Returns the visibility modifier token of this declaration, or null if none is present.
visibilityModifierType¶
Returns the type of the visibility modifier, or null if none is present.
Returns the type of this declaration's visibility modifier, or null if none is present.
visibilityModifierTypeOrDefault¶
Returns the type of this declaration's visibility modifier, or the default visibility (public) if none is present.