Companion¶
object Companion
Properties¶
AllowedKeywords¶
val AllowedKeywords: KaRenderingOption<context(KaSession, KaRenderingContext) (KtKeywordToken) -> Boolean>
A function specifying which keywords are rendered. A keyword for which the predicate returns false is omitted, together with the whitespace which separates it from what follows.
The option covers the keywords of declarations and types, such as modifiers, fun, class, constructor, where, and dynamic. It does not affect keywords which are part of a value, such as null, true, and false.
By default, all keywords are rendered.
Annotations¶
val Annotations: KaRenderingOption<context(KaSession, KaRenderingContext) (KaAnnotated) -> List<KaAnnotation>>
Computes the annotations to render for an annotated element, in the order they are rendered. An omitted annotation is dropped together with the whitespace which separates it from what follows.
By default, all annotations of the element are rendered in their original order, except for @ParameterName. That annotation is how the name of a function type parameter is encoded, and the name is already rendered as part of the parameter itself (see KaPiece.FunctionTypeParameter), so rendering the annotation as well would duplicate it.
AnnotationsOnNewLine¶
val AnnotationsOnNewLine: KaRenderingOption<context(KaSession, KaRenderingContext) (KaAnnotated) -> Boolean>
Whether the annotations of the given element are placed on their own line rather than inline before it.
ClassMemberOrdering¶
A comparator establishing the order in which class members are rendered.
ClassMembers¶
val ClassMembers: KaRenderingOption<context(KaSession, KaRenderingContext) (KaClassSymbol) -> List<KaSymbol>>
Computes the members to render for a KaClassSymbol, in the order they are gathered.
By default, all declared members of a class, interface or an object are rendered, including both static and non-static ones.
The primary constructor and the properties which it declares are excluded when the primary constructor is rendered in the class header (see PrimaryConstructorInClassHeader), as they are already rendered there.
ClassTypeQualification¶
How qualified class type names are rendered (with the package, with outer classifiers, or as a simple name).
ClassTypeRenderingMode¶
How a class type which involves a type alias is rendered: as the abbreviation (the type alias application), as its expansion, or as one of them with the other in a comment.
The mode is applied to each type as it is rendered, so it also affects nested types, such as type arguments. It runs after TypeTransformation and TypeApproximation.
ContextParametersOnNewLine¶
val ContextParametersOnNewLine: KaRenderingOption<context(KaSession, KaRenderingContext) (KaCallableSymbol) -> Boolean>
Whether the context(...) parameters of the given element are placed on their own line rather than inline.
ExcludedClassMemberOrigins¶
The symbol origins whose members are excluded from a rendered class body (e.g. inherited, generated, or delegated members).
ExtraLineBetweenMembers¶
Whether a blank line separates consecutive members within a class body.
FlexibleTypeShrinking¶
Whether a flexible type is shrunk to its compact form instead of being rendered as the (lower..upper) range of its bounds.
A flexible type whose bounds differ only in nullability is shrunk to its lower bound followed by !, so String..String? is rendered as String!. A flexible type between a mutable collection and its read-only counterpart is shrunk to the collection name carrying a (Mutable) marker, so MutableList<String!>..List<String!>? is rendered as (Mutable)List<String!>!. Any other flexible type has no compact form and is rendered as a range regardless of this option.
The option is applied to each type as it is rendered, so it also affects nested types, such as type arguments.
Flexible types are shrunk by default, as the range form exposes the bounds of a type which cannot be written in Kotlin source code in the first place.
LinkSymbols¶
Whether rendered identifiers are linked to the symbols they reference via KaTextAttribute.Symbol.
When disabled, renderers also skip the symbol resolution which is only needed for linking, such as resolving the segments of qualified class and package names. Disabled by default, as an output which produces plain text drops the links anyway.
Modifiers¶
val Modifiers: KaRenderingOption<context(KaSession, KaRenderingContext) (KaDeclarationSymbol, List<KtModifierKeywordToken>) -> List<KtModifierKeywordToken>>
Transforms the modifiers of a declaration. The transformer may drop, add, or reorder modifiers.
The default modifiers are given in the canonical Kotlin order (see KtTokens.MODIFIER_KEYWORDS_ARRAY), and the returned modifiers are rendered in the order they are returned. As modifiers are keywords, AllowedKeywords is still applied to each of them afterward.
The option covers every modifier of every declaration, including the modifiers of value parameters (vararg, crossinline, noinline) and of type parameters (reified, and the declaration-site variance in/out). It does not cover keywords which are not modifiers, such as fun, val, var, class, or constructor.
By default, the declaration's own modifiers are rendered in the canonical order.
MultilineValueParameterLists¶
Whether a value parameter list with more than one parameter is rendered with each parameter on its own line, with the parentheses on lines of their own. A list with at most one parameter is rendered on a single line regardless of this option.
Disabled by default, so every value parameter list is rendered on a single line, e.g. (a: Int, b: String).
PrimaryConstructorInClassHeader¶
Whether the primary constructor is rendered in the class header (e.g. class Foo(x: Int)) rather than as a body member.
TypeApproximation¶
Whether every rendered KaType is approximated to a type that can be written in Kotlin source code, and in which direction.
The approximation is applied to each type as it is rendered, so it also affects nested types. It runs after TypeTransformation.
TypeTransformation¶
val TypeTransformation: KaRenderingOption<context(KaSession, KaRenderingContext) (KaType) -> KaType>
A transformation applied to every rendered KaType before it is printed.
The transformation is applied to each type as it is rendered, so it also affects nested types, such as type arguments, upper bounds, and the components of flexible and intersection types. It runs before TypeApproximation.
By default, warning-level nullability annotations are treated as strict ones (see augmentedByWarningLevelAnnotations), so @RecentlyNullable X! is rendered as X?.
Functions¶
create¶
fun <T> create(defaultValue: T): KaRenderingOption<T>
Creates a rendering option with the provided defaultValue.