Skip to content

Companion

object Companion

Properties

Annotation

val Annotation: KaPiece<Pair<KaAnnotation, AnnotationUseSiteTarget?>>

A single annotation entry, e.g. @Foo(bar). The annotation class name is rendered as ClassName, respecting KaRenderingOption.ClassTypeQualification.

The second component is the use-site target which the annotation is rendered with, e.g. @get:Foo(bar), or null when it is rendered without one.

Annotations

val Annotations: KaPiece<Pair<KaAnnotated, AnnotationUseSiteTarget?>>

The annotations of an annotated element, including the whitespace which separates them from what follows.

Which annotations are rendered is controlled by KaRenderingOption.Annotations, and whether each is followed by a line break or a space by KaRenderingOption.AnnotationsOnNewLine.

The second component is the use-site target which the annotations are rendered with, e.g. @receiver:Foo, or null when they are rendered without one.

AnnotationValue

A single annotation argument value (a constant, enum entry, class literal, nested annotation, or array).

AnnotationValues

The parenthesized argument list of an annotation, e.g. (message = "Use bar"). Nothing is rendered for an annotation without arguments.

AnonymousFunction

An anonymous function, e.g. fun(x: Int): String { ... }.

AnonymousObject

An anonymous object, e.g. object : Runnable { ... }.

BackingField

The declaration of a property's backing field, e.g. field: MutableList<String>.

Callable

Any org.jetbrains.kotlin.analysis.api.symbols.KaCallableSymbol. Dispatches to Function for function-like declarations and to Variable for variable-like declarations.

CapturedType

A captured type produced by capturing a projection during type inference, rendered as Captured(out Number).

Class

Any class, object, or interface declaration (org.jetbrains.kotlin.analysis.api.symbols.KaClassSymbol). Dispatches to NamedClass or AnonymousObject.

ClassAnnotations

The annotations of a class.

ClassBody

The body of a class, containing its member declarations, including the braces and the leading space, e.g. { ... }. Nothing is rendered for an empty body. The rendered members and their layout are controlled by KaRenderingOption.ClassMembers, KaRenderingOption.ClassMemberOrdering, and KaRenderingOption.ExtraLineBetweenMembers.

Classifier

Any classifier declaration (org.jetbrains.kotlin.analysis.api.symbols.KaClassifierSymbol). Dispatches to the piece of its kind: Class, TypeAlias, or TypeParameter.

ClassInitializer

A class initializer block, rendered as init.

ClassName

val ClassName: KaPiece<ClassId>

The qualified name of a class, rendered segment by segment, e.g. Foo.Bar. How qualified the name is rendered is controlled by KaRenderingOption.ClassTypeQualification. Each segment is linked to the classifier it names, when KaRenderingOption.LinkSymbols is enabled and it can be resolved.

The piece is used in positions which name a class without type arguments, such as annotations. The name of a class type, which includes the type arguments of each rendered qualifier segment, is ClassTypeName.

ClassType

A class type, e.g. List<String>?, comprising its TypeAnnotations, ClassTypeName, and TypeNullability.

ClassTypeName

The name of a class type, e.g. Foo.Bar or Int for Foo.Bar<Int>. How the qualified name is rendered is controlled by KaRenderingOption.ClassTypeQualification.

ConstantValue

A constant value, e.g. 42, "text", or null.

Constructor

A constructor declaration.

ConstructorBody

The body of a constructor, including whatever separates it from the signature, e.g. { ... }. The body is not part of the symbol, so nothing is rendered by default.

The piece is not rendered for PrimaryConstructors as they do not have a body.

ContextParameter

A single context parameter.

ContextParameterAnnotations

The annotations of a context parameter.

ContextParameterList

The context(...) clause of a callable, followed by a line break or a space (see KaRenderingOption.ContextParametersOnNewLine). Nothing is rendered when there are no context parameters.

ContextParameterType

The type of context parameter, including the leading colon, e.g. : String.

Declaration

DefinitelyNotNullType

A definitely non-nullable type, e.g. T & Any.

DestructuringDeclaration

A destructuring declaration, e.g. val (a, b). The names of the created variables are rendered as SymbolNames.

The declaration's own val/var keyword and its initializer expression are not part of the symbol: the keyword is taken from the entries, and nothing is rendered after the entry list.

DynamicType

The Kotlin/JS dynamic type.

EnumEntry

A single enum entry, including its anonymous object body when present, e.g. ENTRY { ... }.

ErrorType

A type that could not be resolved. An unresolved class type is rendered in its written form, e.g. C<String>; other error types are rendered as an error marker.

File

A Kotlin file. As a file declares no header of its own, only the file's annotations are rendered, each with the file use-site target, e.g. @file:JvmName("Foo").

FlexibleType

A flexible type spanning a lower and an upper bound, such as a platform type. With KaRenderingOption.FlexibleTypeShrinking (the default), it is rendered compactly when possible, e.g. String!; otherwise as the (lower..upper) range of its bounds.

Function

Any function-like declaration (org.jetbrains.kotlin.analysis.api.symbols.KaFunctionSymbol). Dispatches to the piece of its kind: NamedFunction, Constructor (both primary and secondary), PropertyAccessor, SamConstructor, or AnonymousFunction.

FunctionAnnotations

The annotations of a function.

FunctionBody

The body of a function, including whatever separates it from the signature, e.g. { ... } or = 42. The body is not part of the symbol, so nothing is rendered by default.

The piece covers named functions, anonymous functions, SAM constructors, and property accessors. The body of a constructor is rendered as ConstructorBody instead.

FunctionReturnType

The return type of function, including the leading colon, e.g. : String. The type is always rendered.

FunctionType

A function type rendered with function type syntax, e.g. (Int) -> String. A nullable or annotated function type is wrapped in parentheses, e.g. ((Int) -> String)?.

By default, a reflection function type, such as KFunction1<Int, String>, is rendered as a ClassType as there is no type syntax for reflection types.

FunctionTypeParameter

A single value parameter of a FunctionType, e.g. x: Int in (x: Int) -> String, or just Int for a parameter which has no name.

A function type parameter is named by a synthetic @ParameterName annotation on its type, so a parameter only has a name when that annotation is present.

IntersectionType

An intersection of several types, e.g. A & B.

JavaField

A field declared in Java.

LocalVariable

A local variable declaration.

NamedClass

A named class, interface, or object declaration. The primary constructor is rendered in the class header when KaRenderingOption.PrimaryConstructorInClassHeader is set (the default).

NamedFunction

A named function declaration.

NamedFunctionReturnType

The return type of named function, including the leading colon, e.g. : String. Nothing is rendered for an implicit Unit return type.

Package

A package, e.g. package kotlin.collections.

PackageName

val PackageName: KaPiece<FqName>

The fully-qualified name of a package, rendered segment by segment, e.g. org.example.

Each segment is linked to the KaPackageSymbol of the package it forms, when KaRenderingOption.LinkSymbols is enabled and that package can be resolved.

The piece renders the segments alone. A dot which separates the package name from what follows, such as the dot in a fully qualified class name, is rendered by the piece that requested it.

Parameter

PrimaryConstructor

The primary constructor of a class, as rendered in the class header, e.g. (x: Int) in class Foo(x: Int) (see KaRenderingOption.PrimaryConstructorInClassHeader).

A primary constructor with annotations or an explicit visibility is rendered with a leading space and the constructor keyword, as in class Foo private constructor(x: Int). Without parameters, the parentheses are omitted.

Property

A property declaration (val or var).

PropertyAccessor

A property getter or setter.

PropertyAccessors

The accessors of a property which are rendered below it, each on its own indented line: the non-default accessors, and the default accessors carrying annotations.

PropertyAnnotations

The annotations of a property, including those of its backing field and default setter parameter, which have no rendered declaration of their own and so are rendered here with use-site targets, e.g. @field:Foo.

PropertyInitializer

The initializer of a property, including the leading =, e.g. = 42.

Only the initializer of a const property is rendered by default, as it is a compile-time constant which is part of the property's declaration in source code.

PropertyReturnType

The type of property, including the leading colon, e.g. : String.

ReceiverParameter

The receiver of an extension callable, including the trailing dot, e.g. String. in fun String.foo(). A function type or definitely non-nullable receiver is parenthesized, e.g. (() -> Unit)..

SamConstructor

A SAM constructor: the synthetic function which creates an instance of a functional interface from a lambda, e.g. fun Runnable(function: () -> Unit): Runnable.

Script

A Kotlin script. Nothing is rendered by default.

Supertype

A single supertype, including the constructor call parentheses of a class supertype, e.g. Base().

SupertypeList

The supertype list of a class, including the leading colon, e.g. : Base(), Runnable. Nothing is rendered when there are no non-trivial supertypes (Any and the implicit Enum/Annotation supertypes are omitted).

Symbol

Any org.jetbrains.kotlin.analysis.api.symbols.KaSymbol. Dispatches to a more specific symbol piece depending on the symbol kind: Declaration for declarations, Package for packages, and File for files.

SymbolModifiers

All modifiers of a declaration in the canonical Kotlin order, each followed by a space, e.g. private abstract. The modifier list can be transformed with KaRenderingOption.Modifiers, and single modifiers filtered out with KaRenderingOption.AllowedKeywords.

SymbolName

The name of a declaration, as rendered in the declaration itself, e.g. foo in fun foo().

Type

TypeAlias

A type alias declaration.

TypeAnnotations

The annotations attached to a KaType, rendered as Annotations (each followed by a space by default).

TypeArgumentList

A comma-separated list of type arguments enclosed in angle brackets, e.g. <Int, String>.

TypeNullability

The nullability marker of a type, e.g. ? in String?. Nothing is rendered for a non-nullable type or a flexible type.

TypeParameter

A single type parameter, including its reified modifier, variance, and a single upper bound, e.g. in T : Number. Multiple upper bounds are rendered in a WhereClause instead.

TypeParameterList

A comma-separated list of the declaration's type parameters enclosed in angle brackets, e.g. <T : Number>. Nothing is rendered when the declaration has no type parameters.

TypeParameterType

A reference to a type parameter, e.g. T.

TypeProjection

A type projection: an explicit type argument with its variance, e.g. Number, out Number, or a star projection *.

Unknown

A dispatcher for KaPieces for which a renderer is not provided. As such a situation should never happen in correct code, the default implementation of Unknown posts an com.intellij.openapi.diagnostic.Logger.error.

ValueParameter

A single value parameter, including its modifiers, name, type, and default value. A parameter which declares a property in the primary constructor also carries the property's modifiers and its val/var (see KaRenderingOption.PrimaryConstructorInClassHeader).

ValueParameterAnnotations

The annotations of a value parameter. For a parameter which declares a property in the primary constructor, the annotations of the property and its components are also rendered here, with use-site targets, e.g. @property:Foo.

ValueParameterDefaultValue

The default value of a value parameter, including the leading =, e.g. = .... Nothing is rendered for a parameter without a default value.

ValueParameterDefaultValueExpression

The default value expression of a value parameter, without the leading =.

The expression is not part of the symbol, so it is rendered as an ... placeholder.

ValueParameterList

The parenthesized value parameter list of a function, e.g. (a: Int, b: String).

ValueParameterType

The type of value parameter, including the leading colon, e.g. : String.

Variable

WhereClause

The where clause listing the bounds of type parameters that have more than one upper bound, including the leading space, e.g. where T : A, T : B. Nothing is rendered when no type parameter has multiple bounds.

Functions

create

fun <T> create(): KaPiece<T>

Creates a new KaPiece.

Important: the Analysis API provides default KaPieceRenderers only for KaPieces listed in this object. For all custom pieces, you must provide the default renderer by yourself. If the renderer is not set for a custom piece, it will be dispatched to Unknown.