Skip to content

org.jetbrains.kotlin.psi

Types

BuilderByPattern

A builder that assembles a createByPattern pattern step by step, appending fixed text, expressions, type references, names, and child ranges in order and tracking their placeholders automatically.

FakeImplicitSpreadValueArgumentForCallableReference

A synthetic spread ValueArgument used when modeling the implicit vararg spread of a callable reference.

FakePositionalValueArgumentForCallableReference

A synthetic positional ValueArgument used when modeling the arguments of a callable reference, where arguments have no corresponding source PSI.

IfNotParsed

@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = [ElementType.METHOD])
annotation class IfNotParsed

Comes along with @Nullable to indicate null is only possible if parsing error present

KotlinCodeFragmentImportModificationListener

A listener notified when the imports of a KtCodeFragment are modified.

KotlinDeclarationNavigationPolicy

A service that maps a KtDeclaration between its "original" and its "navigation" element.

KotlinReferenceProvidersService

A project service that collects the PsiReferences contributed to a PSI element by the registered reference providers.

KotlinStringLiteralTextEscaper

A LiteralTextEscaper for Kotlin string literals, enabling language injection into them.

KtAnnotated

interface KtAnnotated : KtElement

Represents an element that owns annotations (the element may or may not be the parent for the annotations).

KtAnnotatedExpression

Represents an expression with annotations applied to it.

KtAnnotation

Represents a bracketed group of annotation entries applied to the same use-site target, which avoids repeating the target for each entry.

KtAnnotationEntry

Represents a single annotation applied to a declaration or expression.

KtAnnotationsContainer

Represents an element that may contain annotations (the container is the parent for them).

KtAnnotationUseSiteTarget

Represents an annotation use-site target that specifies where the annotation should be applied.

KtAnonymousInitializer

Represents an anonymous initializer: a piece of code that runs during initialization without introducing a named declaration.

KtArrayAccessExpression

Represents an indexed access expression using square brackets.

KtBackingField

KtBinaryExpression

Represents a binary expression with a left operand, operator, and right operand.

KtBinaryExpressionWithTypeRHS

Represents a type cast expression using as or as?.

KtBlockCodeFragment

class KtBlockCodeFragment(
    viewProvider: FileViewProvider, 
    imports: String?, 
    context: PsiElement?
) : KtCodeFragment

A KtCodeFragment whose content is a block of statements, as opposed to a single expression.

KtBlockExpression

open class KtBlockExpression : LazyParseablePsiElement, KtElement, KtExpression, KtStatementExpression

Represents a block of statements enclosed in curly braces.

KtBlockStringTemplateEntry

Represents a block interpolation in a string template using ${expression}.

KtBreakExpression

Represents a break expression that terminates the enclosing loop.

KtCallableDeclaration

Represents a declaration with the structure of a callable: it may declare value parameters, an extension receiver, type parameters (with constraints), and a return type.

KtCallableReferenceExpression

Represents a callable reference expression using double colon syntax.

KtCallElement

Represents an element with call syntax: a callee together with type arguments and value arguments.

KtCallExpression

Represents a function call expression, including the callee and arguments.

KtCatchClause

Represents a catch clause in a try expression.

KtClass

Represents a class or interface declaration.

KtClassBody

Represents the body of a class or object declaration enclosed in curly braces.

KtClassInitializer

Represents an init block in a class that executes during instance initialization.

KtClassLikeDeclaration

Represents a declaration that introduces a classifier referable by a ClassId, namely a class, interface, object, or type alias.

KtClassLiteralExpression

Represents a class literal expression that gets a class reference.

KtClassOrObject

KtCodeFragment

@SubclassOptInRequired(markerClass = [KtImplementationDetail::class])
abstract class KtCodeFragment(
    viewProvider: FileViewProvider, 
    imports: String?, 
    elementType: IElementType, 
    context: PsiElement?
) : KtFile, KtCodeFragmentBase

A synthetic, in-memory Kotlin file that holds a standalone snippet of code together with a context.

KtCodeFragmentBase

interface KtCodeFragmentBase : JavaCodeFragment

The Java-interop base for KtCodeFragment, adapting the platform's JavaCodeFragment contract to Kotlin.

KtCollectionLiteralExpression

KtCompanionBlock

KtConstantExpression

Represents a constant literal expression such as numbers, booleans, or characters.

KtConstructor

Represents a constructor of a class or object.

KtConstructorCalleeExpression

Represents the callee part in a constructor invocation, such as in annotations or super type calls.

KtConstructorDelegationCall

Represents a constructor delegation call to this() or super().

KtConstructorDelegationReferenceExpression

Represents the this or super reference in a constructor delegation call.

KtContainerNode

Represents an auxiliary container node that wraps other PSI elements without adding semantic meaning.

KtContainerNodeForControlStructureBody

A wrapper node that holds the body of a control structure, such as an if/else branch or a loop body.

KtContextParameterList

The class representing a context parameter list in a declaration or functional type.

KtContextReceiver

Represents a single context receiver in a context receiver list.

KtContextReceiverList

Represents a list of context receivers declared on a function, property, or class.

KtContinueExpression

Represents a continue expression that skips to the next iteration of the enclosing loop.

KtContractEffect

Represents a single effect declaration inside a contract block.

KtContractEffectList

Represents the list of contract effects in a contract block.

KtDeclaration

Represents a Kotlin declaration: a construct that introduces a named or structural entity, such as a class, function, property, type alias, parameter, or type parameter.

KtDeclarationContainer

Represents an element that contains a list of declarations, such as a file, a class or object body, or a script.

KtDeclarationImpl

Base implementation of KtDeclaration backed directly by the AST tree.

KtDeclarationModifierList

Represents a modifier list attached to a declaration.

KtDeclarationStub

abstract class KtDeclarationStub<T : StubElement<*>?> : KtModifierListOwnerStub<T> , KtDeclaration

Base implementation of KtDeclaration that may be backed either by the AST tree or by a stub.

KtDeclarationWithBody

Represents a declaration that can have a body, such as a function, a property accessor, or an anonymous initializer.

KtDeclarationWithInitializer

Represents a declaration that can have an expression after =, such as a property, a destructuring declaration, a named function, or a property accessor.

KtDeclarationWithReturnType

Represents a Kotlin declaration that semantically has a return type (ex.

KtDelegatedSuperTypeEntry

Represents an interface delegation in the super type list using the by keyword.

KtDestructuringDeclaration

Represents a destructuring declaration that unpacks an object into multiple variables.

KtDestructuringDeclarationEntry

open class KtDestructuringDeclarationEntry : KtNamedDeclarationNotStubbed, KtVariableDeclaration, KtResolvableCall

Represents a single entry in a destructuring declaration.

KtDotQualifiedExpression

Represents a dot-qualified expression for member/extension access.

KtDoubleColonExpression

Represents an expression that uses the :: token, namely a callable reference or a class literal.

KtDoWhileExpression

Represents a do-while loop that executes its body at least once before checking the condition.

KtDynamicType

Represents the dynamic type used in Kotlin/JS for interoperability.

KtElement

@SubclassOptInRequired(markerClass = [KtImplementationDetail::class])
interface KtElement : NavigatablePsiElement, KtPureElement

The root interface of the Kotlin PSI (Program Structure Interface) hierarchy.

KtElementImpl

open class KtElementImpl : ASTWrapperPsiElement, KtElement

Base implementation of KtElement backed directly by the AST tree.

KtElementImplStub

open class KtElementImplStub<T : StubElement<*>?> : StubBasedPsiElementBase<T> , KtElement, StubBasedPsiElement<T> 

Base implementation of KtElement that may be backed either by the AST tree or by a stub.

KtEnumEntry

Represents an enum entry within an enum class.

KtEnumEntrySuperclassReferenceExpression

Represents a synthetic reference to the enum class constructor in an enum entry initializer.

KtErrorSafeQualifiedExpression

Represents an error-safe-call expression using the |. operator.

KtEscapeStringTemplateEntry

Represents an escape sequence in a string template.

KtExperimentalApi

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS])
@RequiresOptIn(message = "Experimental API with no compatibility guarantees")
annotation class KtExperimentalApi

Marks an API as experimental. The API is intended for user consumption, but it's not stable and might change at any moment, or even be removed, without a deprecation cycle.

KtExpression

interface KtExpression : KtElement

Represents a Kotlin expression: a piece of code that can be evaluated to a value, such as a literal, an operator application, a function call, or an if/when used as a value.

KtExpressionCodeFragment

class KtExpressionCodeFragment(
    project: Project, 
    name: String, 
    text: CharSequence, 
    imports: String?, 
    context: PsiElement?
) : KtCodeFragment

A KtCodeFragment whose content is a single expression.

KtExpressionImpl

Base implementation of KtExpression backed directly by the AST tree.

KtExpressionImplStub

abstract class KtExpressionImplStub<T : StubElement<*>?> : KtElementImplStub<T> , KtExpression

Base implementation of KtExpression that may be backed either by the AST tree or by a stub.

KtExpressionWithLabel

Represents an expression that may contain a label qualifier. A KtLabeledExpression declares a label with label@, while labeled break/continue, qualified return, and qualified this/super expressions reference one with @label.

KtFile

@SubclassOptInRequired(markerClass = [KtImplementationDetail::class])
open class KtFile(viewProvider: FileViewProvider, isCompiled: Boolean) : KtCommonFile, PsiClassOwner

The root of the PSI tree for a Kotlin source or script file.

KtFileAnnotationList

Represents a list of file-level annotations at the beginning of a Kotlin file.

KtFileClassProvider

A service that computes the Java light classes exposed by a KtFile (its file facade class and top-level class declarations).

KtFinallySection

Represents a finally block in a try expression.

KtForExpression

Represents a for loop.

KtFunction

Represents a function: a named function, a function literal (lambda or anonymous function), or a constructor.

KtFunctionLiteral

Represents the body of a lambda expression, containing parameters and the function body.

KtFunctionNotStubbed

abstract class KtFunctionNotStubbed : KtTypeParameterListOwnerNotStubbed, KtFunction

Base implementation of KtFunction for functions that are never backed by a stub, such as function literals and anonymous functions.

KtFunctionType

Represents a function type with parameters and return type.

KtFunctionTypeReceiver

Represents the receiver type in a function type with receiver.

KtIdeApi

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS])
@RequiresOptIn(message = "Internal API which is used only from the IntelliJ Kotlin plugin. Such an API should not be used in other places since it has no compatibility guarantees")
annotation class KtIdeApi

Marks an API as designed for and internal to the Kotlin IntelliJ plugin. The API is not intended for public user consumption and does not have any compatibility guarantees.

KtIfExpression

Represents an if expression with condition, then branch, and optional else branch.

KtImplementationDetail

@RequiresOptIn(message = "Internal API which should not be used outside the Kotlin PSI API implementation modules as it does not have any compatibility guarantees")
annotation class KtImplementationDetail

Marks an API as an implementation detail of the Kotlin PSI API. Such APIs are not intended to be used outside the implementation of the PSI API and have no compatibility guarantees.

KtImportAlias

class KtImportAlias : KtElementImplStub<KotlinImportAliasStub> , PsiNameIdentifierOwner

Represents an import alias that provides an alternative name for an imported declaration.

KtImportDirective

Represents a single import directive.

KtImportInfo

interface KtImportInfo

A representation-agnostic view of a single import statement.

KtImportList

Represents the list of import directives in a Kotlin file.

KtInitializerList

Represents the initializer list for an enum entry with constructor arguments.

KtInstanceExpressionWithLabel

A common base class for this and super expressions, both of which refer to an instance receiver and may have an optional label qualifier.

KtIntersectionType

Represents an intersection type combining two types with {@code &}.

KtIsExpression

Represents a type check expression using is or !is.

KtLabeledExpression

class KtLabeledExpression : KtExpressionWithLabel, PsiNameIdentifierOwner

Represents a labeled expression with a label prefix.

KtLabelReferenceExpression

Represents a reference to a label in a labeled expression, such as @main in return@main.

KtLambdaArgument

Represents a trailing lambda argument passed outside of parentheses.

KtLambdaExpression

open class KtLambdaExpression : LazyParseablePsiElement, KtExpression

Represents a lambda expression with optional parameters and a body.

KtLiteralStringTemplateEntry

Represents a literal text segment in a string template without any interpolation.

KtLoopExpression

Represents a loop expression: a for, while, or do-while loop.

KtModifierList

Represents the list of modifiers and annotations that precede a declaration or other KtModifierListOwner.

KtModifierListOwner

interface KtModifierListOwner : PsiElement, KtAnnotated

Represents an element that may own a KtModifierList, that is, a sequence of modifiers (such as public, inline, suspend) and annotations.

KtModifierListOwnerStub

open class KtModifierListOwnerStub<T : StubElement<*>?> : KtElementImplStub<T> , KtModifierListOwner

Base implementation of KtModifierListOwner that may be backed either by the AST tree or by a stub.

KtNamed

interface KtNamed

Represents an element that carries a Kotlin Name, such as a named declaration or a label.

KtNamedDeclaration

interface KtNamedDeclaration : KtDeclaration, PsiNameIdentifierOwner, KtStatementExpression, KtNamed

Represents a KtDeclaration that introduces a name, such as a class, function, property, or type alias.

KtNamedDeclarationStub

Base implementation of KtNamedDeclaration that may be backed either by the AST tree or by a stub.

KtNamedDeclarationUtil

Static helpers for computing fully qualified names of KtNamedDeclarations from their PSI structure.

KtNamedFunction

KtNameReferenceExpression

Represents a simple name reference to a variable, function, or type.

KtNonPublicApi

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS])
@RequiresOptIn(message = "Internal API which is used in projects developed by JetBrains")
annotation class KtNonPublicApi

Marks an API as internal to projects developed by JetBrains. Such APIs are not intended for public user consumption and have less strict compatibility guarantees. For example, a change to the API might be implemented without a deprecation cycle.

KtNullableType

Represents a nullable type marked with a question mark.

KtObjectDeclaration

Represents an object declaration, including companion objects and named objects.

KtObjectLiteralExpression

Represents an object literal expression that creates an anonymous object.

KtOperationExpression

Represents an expression built around an operation sign, such as a unary, binary, or "is"/"as" expression.

KtOperationReferenceExpression

KtPackageDirective

Represents a package directive that declares the package of a Kotlin file.

KtParameter

Represents a parameter declaration in various contexts.

KtParameterList

Represents a list of parameters in various contexts.

KtParenthesizedExpression

Represents an expression enclosed in parentheses.

KtPlatformInterface

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS])
@RequiresOptIn(message = "An API intended for the Analysis API engine and its platform implementations. The API is neither stable nor intended for consumption by PSI users.")
annotation class KtPlatformInterface

Marks an API intended for the Analysis API engine and its platform implementations.

KtPostfixExpression

Represents a postfix unary expression where the operator follows the operand.

KtPrefixExpression

Represents a prefix unary expression where the operator precedes the operand.

KtPrimaryConstructor

Represents a primary constructor explicitly declared in a class header.

KtProjectionKind

enum class KtProjectionKind

The kind of variance projection applied to a type argument in a KtTypeProjection.

KtProperty

Represents a property declaration with an optional getter and setter.

KtPropertyAccessor

KtPropertyDelegate

Represents a property delegate expression that provides the implementation for property accessors.

KtPsiFactory

class KtPsiFactory

A factory for creating Kotlin PSI elements programmatically, usually by parsing a snippet of source text.

KtPsiInconsistencyHandling

Functions and classes annotated with KtPsiInconsistencyHandling are not intended for general-purpose use, but for working with possibly inconsistent PSI. The specific circumstances need to be described in the documentation of the annotated function/class.

KtPsiMutationService

Service responsible for Kotlin PSI mutation operations whose implementation is provided by the Kotlin plugin environment.

KtPsiUtil

open class KtPsiUtil

A collection of static helper methods for working with the Kotlin PSI.

KtPureClassOrObject

A minimal interface that KtClassOrObject implements for the purpose of code-generation that does not need the full power of PSI.

KtPureElement

interface KtPureElement

A minimal interface that KtElement implements for the purpose of code-generation that does not need the full power of PSI.

KtQualifiedExpression

Represents a qualified expression, which accesses a member or extension on a receiver using the ., ?., or |. operator.

KtReferenceExpression

Represents an expression that references a declaration and can therefore be resolved to it, such as a name reference, an array access, or a call expression.

KtReturnExpression

Represents a return expression that returns a value from a function or lambda.

KtSafeQualifiedExpression

Represents a safe-call expression using the ?. operator.

KtScript

Represents a Kotlin script file containing top-level statements and declarations.

KtScriptInitializer

Represents an initializer expression in a script. Effectively, it is a wrapper for top-level expressions

KtSecondaryConstructor

Represents a secondary constructor declared in the class body.

KtSimpleNameExpression

Represents a simple name reference: an unqualified reference to a declaration by its name, or an operation sign that references a declaration (for example, the + of a binary expression).

KtSimpleNameExpressionImpl

Base implementation of KtSimpleNameExpression shared by its stub-based and AST-based variants.

KtSimpleNameStringTemplateEntry

Represents a simple variable interpolation in a string template using $name.

KtSpiExtensionPoint

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY])
@RequiresOptIn(message = "An API designed for implementation only. Direct usage has no compatibility guarantees.")
annotation class KtSpiExtensionPoint

Marks an API as a service provider interface extension point. Such APIs are designed to be implemented, not called directly. There are no compatibility guarantees for usage of these APIs, only for their implementation.

KtStatementExpression

This is an interface to show that KtExpression is not actually an expression (in the sense that this expression can be placed after "val x = ").

KtStringInterpolationPrefix

Represents the multi-dollar interpolation prefix for string templates.

KtStringTemplateEntry

Represents a single entry of a KtStringTemplateExpression, that is, one segment of a string literal.

KtStringTemplateEntryWithExpression

Represents a string template entry that interpolates an expression, using either the $name or the ${...} syntax.

KtStringTemplateExpression

open class KtStringTemplateExpression : KtExpressionImplStub<KotlinPlaceHolderStub<KtStringTemplateExpression>> , PsiLanguageInjectionHost, ContributedReferenceHost

Represents a string literal, including simple strings and string templates with interpolation.

KtStubbedPsiUtil

Static helpers for navigating the Kotlin PSI in a way that also works over stubs.

KtSuperExpression

Represents a super expression that refers to the superclass implementation.

KtSuperTypeCallEntry

Represents a superclass constructor call in the super type list.

KtSuperTypeEntry

Represents an interface type in the super type list (without a constructor call).

KtSuperTypeList

Represents the list of super types after the colon in a class header.

KtSuperTypeListEntry

Represents a single entry in a super type list.

KtThisExpression

Represents a this expression that refers to the current receiver.

KtThrowExpression

Represents a throw expression that throws an exception.

KtTreeVisitor

open class KtTreeVisitor<D> : KtVisitor<Void, D> 

A KtVisitor that recursively traverses the whole PSI subtree.

KtTreeVisitorVoid

A KtVisitorVoid that recursively traverses the whole PSI subtree.

KtTryExpression

Represents a try expression with catch clauses and optional finally block.

KtTypeAlias

KtTypeArgumentList

Represents a list of type arguments in angle brackets.

KtTypeCodeFragment

class KtTypeCodeFragment(
    project: Project, 
    name: String, 
    text: CharSequence, 
    context: PsiElement?
) : KtCodeFragment

A KtCodeFragment whose content is a type reference.

KtTypeConstraint

Represents a single type constraint in a where clause.

KtTypeConstraintList

Represents a where clause containing type constraints.

KtTypeElement

interface KtTypeElement : KtElement

Represents the actual type syntax inside a KtTypeReference, stripped of any leading annotations and modifiers.

KtTypeParameter

Represents a type parameter in a generic declaration.

KtTypeParameterList

Represents a list of type parameters in angle brackets.

KtTypeParameterListOwner

Represents a declaration that may declare type parameters, such as a class, function, or type alias.

KtTypeParameterListOwnerStub

Base implementation of KtTypeParameterListOwner that may be backed either by the AST tree or by a stub.

KtTypeProjection

Represents a type projection in a type argument, including variance modifiers or star projection.

KtTypeReference

KtUnaryExpression

Represents a unary expression with an operator and a single operand.

KtUnionType

Represents an union type combining two types with {@code |}.

KtUserType

Represents a simple type, optionally with type arguments.

KtValueArgument

Represents a value argument in a function call.

KtValueArgumentList

Represents a parenthesized list of value arguments in a call.

KtValueArgumentName

Represents the name part of a named argument.

KtValVarKeywordOwner

interface KtValVarKeywordOwner : PsiElement

Represents an element that may be introduced by a val or var keyword, such as a property, a destructuring entry, or a constructor value parameter.

KtVariableDeclaration

Represents a variable declaration introduced by val or var: a property, a local variable, or an entry of a destructuring declaration.

KtVisitor

open class KtVisitor<R, D> : PsiElementVisitor

The base visitor over the Kotlin PSI, implementing the visitor pattern for KtElements.

KtVisitorVoid

open class KtVisitorVoid : KtVisitor<Void, Void> 

A convenience KtVisitor for the common case of a visitor that returns nothing and needs no extra data.

KtVisitorVoidWithParameter

A convenience KtVisitor for visitors that return nothing but still thread a data parameter through the traversal.

KtWhenCondition

abstract class KtWhenCondition : KtElementImpl

Represents a single condition of a KtWhenEntry in a when expression.

KtWhenConditionInRange

Represents a when condition that checks membership using in or !in.

KtWhenConditionIsPattern

Represents a when condition that performs a type check using is or !is.

KtWhenConditionWithExpression

Represents a when condition that matches against an expression value.

KtWhenEntry

open class KtWhenEntry : KtElementImpl

Represents a single branch in a when expression.

KtWhenEntryGuard

Represents a guard condition in a when entry using the if keyword.

KtWhenExpression

Represents a when expression with an optional subject and multiple branches.

KtWhileExpression

Represents a while loop that executes its body while the condition is true.

KtWhileExpressionBase

Represents a condition-driven loop: a while or do-while loop.

LambdaArgument

A ValueArgument that is a trailing lambda passed outside the call parentheses, as in list.forEach { ... }.

UserDataProperty

class UserDataProperty<in R : UserDataHolder, T : Any>(val key: Key<T>)

A property delegate that reads and writes a value stored in a UserDataHolder under the given key.

ValueArgument

interface ValueArgument

Represents a single argument passed in a call, such as foo(1, message = "hi", *array).

ValueArgumentName

interface ValueArgumentName

The name of a named ValueArgument (the name in name = value).

Properties

Functions

buildByPattern

fun <TElement> buildByPattern(factory: (String, Array<out Any>) -> TElement, build: BuilderByPattern<TElement>.() -> Unit): TElement

Creates a BuilderByPattern, runs build on it, and produces the element via factory. Backs the KtPsiFactory.build* entry points.

createByPattern

fun <TElement : KtElement> createByPattern(
    pattern: String, 
    vararg args: Any, 
    reformat: Boolean = true, 
    factory: (String) -> TElement
): TElement

Creates a PSI element from a textual pattern with $0, $1, … placeholders replaced by the corresponding args.