[Analysis API] remove old renderer code

This commit is contained in:
Ilya Kirillov
2022-10-28 10:59:21 +02:00
parent 10b593ba8c
commit b47675916f
13 changed files with 33 additions and 1753 deletions
@@ -11,124 +11,9 @@ import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclaratio
import org.jetbrains.kotlin.analysis.api.renderer.types.KtTypeRenderer
import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KtTypeRendererForSource
import org.jetbrains.kotlin.analysis.api.symbols.KtDeclarationSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.types.Variance
/**
* KtType to string renderer options
* @see KtType
* @see KtSymbolDeclarationRendererProvider.renderType
*/
public data class KtTypeRendererOptions(
/**
* Render type name without package name for not local types
*/
public val shortQualifiedNames: Boolean = false,
/**
* Render public function types public functionN using Kotlin public function type syntax
* @see public function
* @sample public function0<Int> returns () -> Int
*/
public val renderFunctionType: Boolean = true,
/**
* When met type with unresolved qualifier, render it as it is resolved
* When `true` will render as `UnresolvedQualifier`
* When `false` will render as "ERROR_TYPE <symbol not found for UnresolvedQualifier>"
*/
public val renderUnresolvedTypeAsResolved: Boolean = true,
/**
* Should annotations on types be rendered.
*/
public val renderTypeAnnotations: Boolean = true
) {
public companion object {
public val DEFAULT: KtTypeRendererOptions = KtTypeRendererOptions()
public val SHORT_NAMES: KtTypeRendererOptions = DEFAULT.copy(shortQualifiedNames = true)
}
}
/**
* KtSymbol to string renderer options
* @see KtSymbol
* @see KtSymbolDeclarationRendererProvider.renderType
*/
public data class KtDeclarationRendererOptions(
/**
* Set of modifiers that needed to be rendered
* @see RendererModifier
*/
val modifiers: Set<RendererModifier> = RendererModifier.ALL,
/**
* Type render options @see KtTypeRendererOptions
* @see KtTypeRendererOptions
*/
val typeRendererOptions: KtTypeRendererOptions = KtTypeRendererOptions.DEFAULT,
/**
* Render Unit return type for public functions
*/
val renderUnitReturnType: Boolean = false,
/**
* Normalize java-specific visibilities for java declaration
*/
val normalizedVisibilities: Boolean = false,
/**
* Render members of a classes and objects if any
*/
val renderClassMembers: Boolean = false,
/**
* Approximate Kotlin not-denotable types into denotable for declarations return type
*/
val approximateTypes: Boolean = false,
/**
* Declaration header is something like `public abstract class`, `public fun`, or `private public interface ` in a declaration.
*/
val renderDeclarationHeader: Boolean = true,
/**
* Whether to forcefully add `override` modifier when rendering public functions or properties. Note that the [modifiers] option still
* controls whether `override` is rendered. That is, if [modifiers] don't contain `override`, then this flag does not have any effect.
*/
val forceRenderingOverrideModifier: Boolean = false,
val renderDefaultParameterValue: Boolean = true,
/**
* Sort nested declarations by kind (enum values, then constructors, then properties, then functions) and name.
*/
val sortNestedDeclarations: Boolean = false,
) {
public companion object {
public val DEFAULT: KtDeclarationRendererOptions = KtDeclarationRendererOptions()
}
}
public enum class RendererModifier(public val includeByDefault: Boolean) {
VISIBILITY(true),
MODALITY(true),
OVERRIDE(true),
ANNOTATIONS(false),
INNER(true),
DATA(true),
INLINE(true),
EXPECT(true),
ACTUAL(true),
CONST(true),
LATEINIT(true),
FUN(true),
VALUE(true),
OPERATOR(true)
;
public companion object {
public val ALL: Set<RendererModifier> = values().toSet()
public val DEFAULT: Set<RendererModifier> = values().filterTo(mutableSetOf()) { it.includeByDefault }
public val NONE: Set<RendererModifier> = emptySet()
}
}
public abstract class KtSymbolDeclarationRendererProvider : KtAnalysisSessionComponent() {
public abstract fun renderDeclaration(symbol: KtDeclarationSymbol, renderer: KtDeclarationRenderer): String