[AA] introduce KtKeywordsRenderer to support nonmodifier keywords filter
This commit is contained in:
+4
-2
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
|||||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.prettyPrintSignature
|
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.prettyPrintSignature
|
||||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation
|
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclarationRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclarationRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererModifierFilter
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererKeywordFilter
|
||||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
||||||
import org.jetbrains.kotlin.analysis.api.scopes.KtTypeScope
|
import org.jetbrains.kotlin.analysis.api.scopes.KtTypeScope
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.DebugSymbolRenderer
|
import org.jetbrains.kotlin.analysis.api.symbols.DebugSymbolRenderer
|
||||||
@@ -98,7 +98,9 @@ abstract class AbstractTypeScopeTest : AbstractAnalysisApiSingleFileTest() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val renderer = KtDeclarationRendererForSource.WITH_QUALIFIED_NAMES.with {
|
private val renderer = KtDeclarationRendererForSource.WITH_QUALIFIED_NAMES.with {
|
||||||
modifiersRenderer = modifiersRenderer.with { modifierFilter = KtRendererModifierFilter.NONE }
|
modifiersRenderer = modifiersRenderer.with {
|
||||||
|
keywordsRenderer = keywordsRenderer.with { keywordFilter = KtRendererKeywordFilter.NONE }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.analysis.api.components.KtScopeContext
|
|||||||
import org.jetbrains.kotlin.analysis.api.components.KtScopeKind
|
import org.jetbrains.kotlin.analysis.api.components.KtScopeKind
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtRendererAnnotationsFilter
|
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtRendererAnnotationsFilter
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclarationRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclarationRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererModifierFilter
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererKeywordFilter
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KtTypeRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KtTypeRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.types.renderers.KtTypeErrorTypeRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.types.renderers.KtTypeErrorTypeRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
||||||
@@ -95,9 +95,9 @@ internal object TestScopeRenderer {
|
|||||||
appendLine()
|
appendLine()
|
||||||
withIndent {
|
withIndent {
|
||||||
appendLine("classifiers: ${classifiers.size}")
|
appendLine("classifiers: ${classifiers.size}")
|
||||||
withIndent { classifiers.forEach { appendLine(TestScopeRenderer.renderSymbol(it, printPretty)) } }
|
withIndent { classifiers.forEach { appendLine(renderSymbol(it, printPretty)) } }
|
||||||
appendLine("callables: ${callables.size}")
|
appendLine("callables: ${callables.size}")
|
||||||
withIndent { callables.forEach { appendLine(TestScopeRenderer.renderSymbol(it, printPretty)) } }
|
withIndent { callables.forEach { appendLine(renderSymbol(it, printPretty)) } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,9 @@ internal object TestScopeRenderer {
|
|||||||
|
|
||||||
private val prettyPrintSymbolRenderer = KtDeclarationRendererForSource.WITH_QUALIFIED_NAMES.with {
|
private val prettyPrintSymbolRenderer = KtDeclarationRendererForSource.WITH_QUALIFIED_NAMES.with {
|
||||||
annotationRenderer = annotationRenderer.with { annotationFilter = KtRendererAnnotationsFilter.NONE }
|
annotationRenderer = annotationRenderer.with { annotationFilter = KtRendererAnnotationsFilter.NONE }
|
||||||
modifiersRenderer = modifiersRenderer.with { modifierFilter = KtRendererModifierFilter.NONE }
|
modifiersRenderer = modifiersRenderer.with {
|
||||||
|
keywordsRenderer = keywordsRenderer.with { keywordFilter = KtRendererKeywordFilter.NONE }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val prettyPrintTypeRenderer = KtTypeRendererForSource.WITH_QUALIFIED_NAMES.with {
|
private val prettyPrintTypeRenderer = KtTypeRendererForSource.WITH_QUALIFIED_NAMES.with {
|
||||||
|
|||||||
+2
-2
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.analysis.api.calls.KtCallableMemberCall
|
|||||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
|
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
|
||||||
import org.jetbrains.kotlin.analysis.api.impl.base.KtMapBackedSubstitutor
|
import org.jetbrains.kotlin.analysis.api.impl.base.KtMapBackedSubstitutor
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclarationRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KtDeclarationRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererModifierFilter
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererKeywordFilter
|
||||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
||||||
import org.jetbrains.kotlin.analysis.api.signatures.KtCallableSignature
|
import org.jetbrains.kotlin.analysis.api.signatures.KtCallableSignature
|
||||||
import org.jetbrains.kotlin.analysis.api.signatures.KtFunctionLikeSignature
|
import org.jetbrains.kotlin.analysis.api.signatures.KtFunctionLikeSignature
|
||||||
@@ -185,7 +185,7 @@ internal fun renderScopeWithParentDeclarations(scope: KtScope): String = prettyP
|
|||||||
|
|
||||||
val renderingOptions = KtDeclarationRendererForSource.WITH_SHORT_NAMES.with {
|
val renderingOptions = KtDeclarationRendererForSource.WITH_SHORT_NAMES.with {
|
||||||
modifiersRenderer = modifiersRenderer.with {
|
modifiersRenderer = modifiersRenderer.with {
|
||||||
modifierFilter = KtRendererModifierFilter.NONE
|
keywordsRenderer = keywordsRenderer.with { keywordFilter = KtRendererKeywordFilter.NONE }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -11,25 +11,27 @@ import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
|||||||
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
||||||
|
|
||||||
public interface KtKeywordRenderer {
|
public interface KtKeywordRenderer {
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession, KtKeywordsRenderer)
|
||||||
public fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter)
|
public fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter)
|
||||||
|
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession, KtKeywordsRenderer)
|
||||||
public fun renderKeywords(keywords: List<KtKeywordToken>, owner: KtAnnotated, printer: PrettyPrinter) {
|
public fun renderKeywords(keywords: List<KtKeywordToken>, owner: KtAnnotated, printer: PrettyPrinter) {
|
||||||
printer.printCollection(keywords, separator = " ") {
|
printer.printCollection(keywords.filter { keywordFilter.filter(it, owner) }, separator = " ") {
|
||||||
renderKeyword(it, owner, this)
|
renderKeyword(it, owner, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object AS_WORD : KtKeywordRenderer {
|
public object AS_WORD : KtKeywordRenderer {
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession, KtKeywordsRenderer)
|
||||||
override fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter) {
|
override fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter) {
|
||||||
printer.append(keyword.value)
|
if (keywordFilter.filter(keyword, owner)) {
|
||||||
|
printer.append(keyword.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object NONE : KtKeywordRenderer {
|
public object NONE : KtKeywordRenderer {
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession, KtKeywordsRenderer)
|
||||||
override fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter) {
|
override fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.analysis.api.renderer.base
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotated
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.KtRendererKeywordFilter
|
||||||
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
|
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
||||||
|
|
||||||
|
public class KtKeywordsRenderer private constructor(
|
||||||
|
public val keywordRenderer: KtKeywordRenderer,
|
||||||
|
public val keywordFilter: KtRendererKeywordFilter,
|
||||||
|
) {
|
||||||
|
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
public fun renderKeyword(keyword: KtKeywordToken, owner: KtAnnotated, printer: PrettyPrinter) {
|
||||||
|
keywordRenderer.renderKeyword(keyword, owner, printer)
|
||||||
|
}
|
||||||
|
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
public fun renderKeywords(keywords: List<KtKeywordToken>, owner: KtAnnotated, printer: PrettyPrinter) {
|
||||||
|
keywordRenderer.renderKeywords(keywords, owner, printer)
|
||||||
|
}
|
||||||
|
|
||||||
|
public inline fun with(action: Builder.() -> Unit): KtKeywordsRenderer {
|
||||||
|
val renderer = this
|
||||||
|
return KtKeywordsRenderer {
|
||||||
|
this.keywordRenderer = renderer.keywordRenderer
|
||||||
|
this.keywordFilter = renderer.keywordFilter
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Builder {
|
||||||
|
public lateinit var keywordRenderer: KtKeywordRenderer
|
||||||
|
public lateinit var keywordFilter: KtRendererKeywordFilter
|
||||||
|
|
||||||
|
public fun build(): KtKeywordsRenderer = KtKeywordsRenderer(
|
||||||
|
keywordRenderer,
|
||||||
|
keywordFilter
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
public val AS_WORD: KtKeywordsRenderer = KtKeywordsRenderer(KtKeywordRenderer.AS_WORD, KtRendererKeywordFilter.ALL)
|
||||||
|
public val NONE: KtKeywordsRenderer = KtKeywordsRenderer(KtKeywordRenderer.NONE, KtRendererKeywordFilter.ALL)
|
||||||
|
public inline operator fun invoke(action: Builder.() -> Unit): KtKeywordsRenderer =
|
||||||
|
Builder().apply(action).build()
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-5
@@ -6,7 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.analysis.api.renderer.declarations
|
package org.jetbrains.kotlin.analysis.api.renderer.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordsRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.bodies.*
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.bodies.*
|
||||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
|||||||
|
|
||||||
public class KtDeclarationRenderer private constructor(
|
public class KtDeclarationRenderer private constructor(
|
||||||
public val nameRenderer: KtDeclarationNameRenderer,
|
public val nameRenderer: KtDeclarationNameRenderer,
|
||||||
public val keywordRenderer: KtKeywordRenderer,
|
public val keywordsRenderer: KtKeywordsRenderer,
|
||||||
public val contextReceiversRenderer: KtContextReceiversRenderer,
|
public val contextReceiversRenderer: KtContextReceiversRenderer,
|
||||||
public val codeStyle: KtRendererCodeStyle,
|
public val codeStyle: KtRendererCodeStyle,
|
||||||
public val typeRenderer: KtTypeRenderer,
|
public val typeRenderer: KtTypeRenderer,
|
||||||
@@ -115,7 +115,7 @@ public class KtDeclarationRenderer private constructor(
|
|||||||
val renderer = this
|
val renderer = this
|
||||||
return KtDeclarationRenderer {
|
return KtDeclarationRenderer {
|
||||||
this.nameRenderer = renderer.nameRenderer
|
this.nameRenderer = renderer.nameRenderer
|
||||||
this.keywordRender = renderer.keywordRenderer
|
this.keywordsRenderer = renderer.keywordsRenderer
|
||||||
this.contextReceiversRenderer = renderer.contextReceiversRenderer
|
this.contextReceiversRenderer = renderer.contextReceiversRenderer
|
||||||
this.codeStyle = renderer.codeStyle
|
this.codeStyle = renderer.codeStyle
|
||||||
this.typeRenderer = renderer.typeRenderer
|
this.typeRenderer = renderer.typeRenderer
|
||||||
@@ -185,7 +185,7 @@ public class KtDeclarationRenderer private constructor(
|
|||||||
public lateinit var returnTypeFilter: KtCallableReturnTypeFilter
|
public lateinit var returnTypeFilter: KtCallableReturnTypeFilter
|
||||||
public lateinit var nameRenderer: KtDeclarationNameRenderer
|
public lateinit var nameRenderer: KtDeclarationNameRenderer
|
||||||
public lateinit var contextReceiversRenderer: KtContextReceiversRenderer
|
public lateinit var contextReceiversRenderer: KtContextReceiversRenderer
|
||||||
public lateinit var keywordRender: KtKeywordRenderer
|
public lateinit var keywordsRenderer: KtKeywordsRenderer
|
||||||
public lateinit var codeStyle: KtRendererCodeStyle
|
public lateinit var codeStyle: KtRendererCodeStyle
|
||||||
public lateinit var typeRenderer: KtTypeRenderer
|
public lateinit var typeRenderer: KtTypeRenderer
|
||||||
public lateinit var annotationRenderer: KtAnnotationRenderer
|
public lateinit var annotationRenderer: KtAnnotationRenderer
|
||||||
@@ -241,7 +241,7 @@ public class KtDeclarationRenderer private constructor(
|
|||||||
|
|
||||||
public fun build(): KtDeclarationRenderer = KtDeclarationRenderer(
|
public fun build(): KtDeclarationRenderer = KtDeclarationRenderer(
|
||||||
nameRenderer,
|
nameRenderer,
|
||||||
keywordRender,
|
keywordsRenderer,
|
||||||
contextReceiversRenderer,
|
contextReceiversRenderer,
|
||||||
codeStyle,
|
codeStyle,
|
||||||
typeRenderer,
|
typeRenderer,
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.renderer.declarations.impl
|
package org.jetbrains.kotlin.analysis.api.renderer.declarations.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordsRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtCallableReturnTypeFilter
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtCallableReturnTypeFilter
|
||||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KtTypeRendererForSo
|
|||||||
public object KtDeclarationRendererForSource {
|
public object KtDeclarationRendererForSource {
|
||||||
public val WITH_QUALIFIED_NAMES: KtDeclarationRenderer = KtDeclarationRenderer {
|
public val WITH_QUALIFIED_NAMES: KtDeclarationRenderer = KtDeclarationRenderer {
|
||||||
nameRenderer = KtDeclarationNameRenderer.QUOTED
|
nameRenderer = KtDeclarationNameRenderer.QUOTED
|
||||||
keywordRender = KtKeywordRenderer.AS_WORD
|
keywordsRenderer = KtKeywordsRenderer.AS_WORD
|
||||||
contextReceiversRenderer = KtContextReceiversRendererForSource.WITH_LABELS
|
contextReceiversRenderer = KtContextReceiversRendererForSource.WITH_LABELS
|
||||||
codeStyle = KtRecommendedRendererCodeStyle
|
codeStyle = KtRecommendedRendererCodeStyle
|
||||||
modifiersRenderer = KtDeclarationModifiersRendererForSource.NO_IMPLICIT_MODIFIERS
|
modifiersRenderer = KtDeclarationModifiersRendererForSource.NO_IMPLICIT_MODIFIERS
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public fun <S> renderAnnotationsModifiersAndContextReceivers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
withPrefix(separator) {
|
withPrefix(separator) {
|
||||||
keywordRenderer.renderKeywords(keywords, symbol, printer)
|
keywordsRenderer.renderKeywords(keywords, symbol, printer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-9
@@ -6,19 +6,18 @@
|
|||||||
package org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers
|
package org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordsRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.*
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.*
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtDeclarationSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtDeclarationSymbol
|
||||||
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
|
|
||||||
public class KtDeclarationModifiersRenderer private constructor(
|
public class KtDeclarationModifiersRenderer private constructor(
|
||||||
public val modifierListRenderer: KtModifierListRenderer,
|
public val modifierListRenderer: KtModifierListRenderer,
|
||||||
public val modifierFilter: KtRendererModifierFilter,
|
|
||||||
public val modifiersSorter: KtModifiersSorter,
|
public val modifiersSorter: KtModifiersSorter,
|
||||||
public val modalityProvider: KtRendererModalityModifierProvider,
|
public val modalityProvider: KtRendererModalityModifierProvider,
|
||||||
public val visibilityProvider: KtRendererVisibilityModifierProvider,
|
public val visibilityProvider: KtRendererVisibilityModifierProvider,
|
||||||
public val otherModifiersProvider: KtRendererOtherModifiersProvider,
|
public val otherModifiersProvider: KtRendererOtherModifiersProvider,
|
||||||
public val keywordRenderer: KtKeywordRenderer,
|
public val keywordsRenderer: KtKeywordsRenderer,
|
||||||
) {
|
) {
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
public fun renderDeclarationModifiers(symbol: KtDeclarationSymbol, printer: PrettyPrinter) {
|
public fun renderDeclarationModifiers(symbol: KtDeclarationSymbol, printer: PrettyPrinter) {
|
||||||
@@ -29,12 +28,11 @@ public class KtDeclarationModifiersRenderer private constructor(
|
|||||||
val renderer = this
|
val renderer = this
|
||||||
return KtDeclarationModifiersRenderer {
|
return KtDeclarationModifiersRenderer {
|
||||||
this.modifierListRenderer = renderer.modifierListRenderer
|
this.modifierListRenderer = renderer.modifierListRenderer
|
||||||
this.modifierFilter = renderer.modifierFilter
|
|
||||||
this.modifiersSorter = renderer.modifiersSorter
|
this.modifiersSorter = renderer.modifiersSorter
|
||||||
this.modalityProvider = renderer.modalityProvider
|
this.modalityProvider = renderer.modalityProvider
|
||||||
this.visibilityProvider = renderer.visibilityProvider
|
this.visibilityProvider = renderer.visibilityProvider
|
||||||
this.otherModifiersProvider = renderer.otherModifiersProvider
|
this.otherModifiersProvider = renderer.otherModifiersProvider
|
||||||
this.keywordRenderer = renderer.keywordRenderer
|
this.keywordsRenderer = renderer.keywordsRenderer
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,21 +44,19 @@ public class KtDeclarationModifiersRenderer private constructor(
|
|||||||
|
|
||||||
public class Builder {
|
public class Builder {
|
||||||
public lateinit var modifierListRenderer: KtModifierListRenderer
|
public lateinit var modifierListRenderer: KtModifierListRenderer
|
||||||
public lateinit var modifierFilter: KtRendererModifierFilter
|
|
||||||
public lateinit var modifiersSorter: KtModifiersSorter
|
public lateinit var modifiersSorter: KtModifiersSorter
|
||||||
public lateinit var modalityProvider: KtRendererModalityModifierProvider
|
public lateinit var modalityProvider: KtRendererModalityModifierProvider
|
||||||
public lateinit var visibilityProvider: KtRendererVisibilityModifierProvider
|
public lateinit var visibilityProvider: KtRendererVisibilityModifierProvider
|
||||||
public lateinit var otherModifiersProvider: KtRendererOtherModifiersProvider
|
public lateinit var otherModifiersProvider: KtRendererOtherModifiersProvider
|
||||||
public lateinit var keywordRenderer: KtKeywordRenderer
|
public lateinit var keywordsRenderer: KtKeywordsRenderer
|
||||||
|
|
||||||
public fun build(): KtDeclarationModifiersRenderer = KtDeclarationModifiersRenderer(
|
public fun build(): KtDeclarationModifiersRenderer = KtDeclarationModifiersRenderer(
|
||||||
modifierListRenderer,
|
modifierListRenderer,
|
||||||
modifierFilter,
|
|
||||||
modifiersSorter,
|
modifiersSorter,
|
||||||
modalityProvider,
|
modalityProvider,
|
||||||
visibilityProvider,
|
visibilityProvider,
|
||||||
otherModifiersProvider,
|
otherModifiersProvider,
|
||||||
keywordRenderer,
|
keywordsRenderer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-3
@@ -5,18 +5,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.impl
|
package org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordsRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.KtDeclarationModifiersRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.KtDeclarationModifiersRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.*
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers.*
|
||||||
|
|
||||||
public object KtDeclarationModifiersRendererForSource {
|
public object KtDeclarationModifiersRendererForSource {
|
||||||
public val NO_IMPLICIT_MODIFIERS: KtDeclarationModifiersRenderer = KtDeclarationModifiersRenderer {
|
public val NO_IMPLICIT_MODIFIERS: KtDeclarationModifiersRenderer = KtDeclarationModifiersRenderer {
|
||||||
modifierListRenderer = KtModifierListRenderer.AS_LIST
|
modifierListRenderer = KtModifierListRenderer.AS_LIST
|
||||||
modifierFilter = KtRendererModifierFilter.ALL
|
|
||||||
modifiersSorter = KtModifiersSorter.CANONICAL
|
modifiersSorter = KtModifiersSorter.CANONICAL
|
||||||
modalityProvider = KtRendererModalityModifierProvider.WITHOUT_IMPLICIT_MODALITY
|
modalityProvider = KtRendererModalityModifierProvider.WITHOUT_IMPLICIT_MODALITY
|
||||||
visibilityProvider = KtRendererVisibilityModifierProvider.NO_IMPLICIT_VISIBILITY
|
visibilityProvider = KtRendererVisibilityModifierProvider.NO_IMPLICIT_VISIBILITY
|
||||||
otherModifiersProvider = KtRendererOtherModifiersProvider.ALL
|
otherModifiersProvider = KtRendererOtherModifiersProvider.ALL
|
||||||
keywordRenderer = KtKeywordRenderer.AS_WORD
|
keywordsRenderer = KtKeywordsRenderer.AS_WORD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers
|
||||||
|
|
||||||
|
import com.intellij.psi.tree.TokenSet
|
||||||
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotated
|
||||||
|
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
||||||
|
|
||||||
|
public interface KtRendererKeywordFilter {
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
public fun filter(modifier: KtKeywordToken, ktAnnotated: KtAnnotated): Boolean
|
||||||
|
|
||||||
|
public infix fun and(other: KtRendererKeywordFilter): KtRendererKeywordFilter {
|
||||||
|
val self = this
|
||||||
|
return KtRendererKeywordFilter { modifier, ktAnnotated ->
|
||||||
|
self.filter(modifier, ktAnnotated) && other.filter(modifier, ktAnnotated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public infix fun or(other: KtRendererKeywordFilter): KtRendererKeywordFilter {
|
||||||
|
val self = this
|
||||||
|
return KtRendererKeywordFilter { modifier, symbol ->
|
||||||
|
self.filter(modifier, symbol) || other.filter(modifier, symbol)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ALL : KtRendererKeywordFilter {
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
override fun filter(modifier: KtKeywordToken, ktAnnotated: KtAnnotated): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object NONE : KtRendererKeywordFilter {
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
override fun filter(modifier: KtKeywordToken, ktAnnotated: KtAnnotated): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
public operator fun invoke(
|
||||||
|
predicate: context(KtAnalysisSession)(modifier: KtKeywordToken, ktAnnotated: KtAnnotated) -> Boolean
|
||||||
|
): KtRendererKeywordFilter =
|
||||||
|
object : KtRendererKeywordFilter {
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
override fun filter(modifier: KtKeywordToken, ktAnnotated: KtAnnotated): Boolean {
|
||||||
|
return predicate(this@KtAnalysisSession, modifier, ktAnnotated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun onlyWith(vararg modifiers: KtKeywordToken): KtRendererKeywordFilter =
|
||||||
|
KtRendererKeywordFilter { modifier, _ -> modifier in modifiers }
|
||||||
|
|
||||||
|
public fun onlyWith(modifiers: TokenSet): KtRendererKeywordFilter =
|
||||||
|
KtRendererKeywordFilter { modifier, _ -> modifier in modifiers }
|
||||||
|
|
||||||
|
public fun without(vararg modifiers: KtKeywordToken): KtRendererKeywordFilter =
|
||||||
|
KtRendererKeywordFilter { modifier, _ -> modifier !in modifiers }
|
||||||
|
|
||||||
|
public fun without(modifiers: TokenSet): KtRendererKeywordFilter =
|
||||||
|
KtRendererKeywordFilter { modifier, _ -> modifier !in modifiers }
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-2
@@ -22,10 +22,9 @@ public interface KtModifierListRenderer {
|
|||||||
override fun renderModifiers(symbol: KtDeclarationSymbol, printer: PrettyPrinter) {
|
override fun renderModifiers(symbol: KtDeclarationSymbol, printer: PrettyPrinter) {
|
||||||
val modifiers = getModifiers(symbol)
|
val modifiers = getModifiers(symbol)
|
||||||
.distinct()
|
.distinct()
|
||||||
.filter { modifierFilter.filter(it, symbol) }
|
|
||||||
.let { modifiersSorter.sort(it, symbol) }
|
.let { modifiersSorter.sort(it, symbol) }
|
||||||
.ifEmpty { return }
|
.ifEmpty { return }
|
||||||
keywordRenderer.renderKeywords(modifiers, symbol, printer)
|
keywordsRenderer.renderKeywords(modifiers, symbol, printer)
|
||||||
}
|
}
|
||||||
|
|
||||||
context(KtAnalysisSession, KtDeclarationModifiersRenderer)
|
context(KtAnalysisSession, KtDeclarationModifiersRenderer)
|
||||||
|
|||||||
-68
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.renderer.declarations.modifiers.renderers
|
|
||||||
|
|
||||||
import com.intellij.psi.tree.TokenSet
|
|
||||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtDeclarationSymbol
|
|
||||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
|
||||||
|
|
||||||
public interface KtRendererModifierFilter {
|
|
||||||
context(KtAnalysisSession)
|
|
||||||
public fun filter(modifier: KtModifierKeywordToken, symbol: KtDeclarationSymbol): Boolean
|
|
||||||
|
|
||||||
public infix fun and(other: KtRendererModifierFilter): KtRendererModifierFilter {
|
|
||||||
val self = this
|
|
||||||
return KtRendererModifierFilter { modifier, symbol ->
|
|
||||||
self.filter(modifier, symbol) && other.filter(modifier, symbol)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public infix fun or(other: KtRendererModifierFilter): KtRendererModifierFilter {
|
|
||||||
val self = this
|
|
||||||
return KtRendererModifierFilter { modifier, symbol ->
|
|
||||||
self.filter(modifier, symbol) || other.filter(modifier, symbol)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ALL : KtRendererModifierFilter {
|
|
||||||
context(KtAnalysisSession)
|
|
||||||
override fun filter(modifier: KtModifierKeywordToken, symbol: KtDeclarationSymbol): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public object NONE : KtRendererModifierFilter {
|
|
||||||
context(KtAnalysisSession)
|
|
||||||
override fun filter(modifier: KtModifierKeywordToken, symbol: KtDeclarationSymbol): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public companion object {
|
|
||||||
public operator fun invoke(
|
|
||||||
predicate: context(KtAnalysisSession)(modifier: KtModifierKeywordToken, symbol: KtDeclarationSymbol) -> Boolean
|
|
||||||
): KtRendererModifierFilter =
|
|
||||||
object : KtRendererModifierFilter {
|
|
||||||
context(KtAnalysisSession)
|
|
||||||
override fun filter(modifier: KtModifierKeywordToken, symbol: KtDeclarationSymbol): Boolean {
|
|
||||||
return predicate(this@KtAnalysisSession, modifier, symbol)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun onlyWith(vararg modifiers: KtModifierKeywordToken): KtRendererModifierFilter =
|
|
||||||
KtRendererModifierFilter { modifier, _ -> modifier in modifiers }
|
|
||||||
|
|
||||||
public fun onlyWith(modifiers: TokenSet): KtRendererModifierFilter =
|
|
||||||
KtRendererModifierFilter { modifier, _ -> modifier in modifiers }
|
|
||||||
|
|
||||||
public fun without(vararg modifiers: KtModifierKeywordToken): KtRendererModifierFilter =
|
|
||||||
KtRendererModifierFilter { modifier, _ -> modifier !in modifiers }
|
|
||||||
|
|
||||||
public fun without(modifiers: TokenSet): KtRendererModifierFilter =
|
|
||||||
KtRendererModifierFilter { modifier, _ -> modifier !in modifiers }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-1
@@ -19,7 +19,9 @@ public interface KtClassInitializerRenderer {
|
|||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
override fun renderClassInitializer(symbol: KtClassInitializerSymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderClassInitializer(symbol: KtClassInitializerSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{ keywordRenderer.renderKeyword(KtTokens.INIT_KEYWORD, symbol, this) },
|
{
|
||||||
|
keywordsRenderer.renderKeyword(KtTokens.INIT_KEYWORD, symbol, this)
|
||||||
|
},
|
||||||
{ printer.withIndentInBraces {} },
|
{ printer.withIndentInBraces {} },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -80,7 +80,9 @@ public interface KtTypeParametersRenderer {
|
|||||||
}
|
}
|
||||||
}.ifEmpty { return }
|
}.ifEmpty { return }
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{ keywordRenderer.renderKeyword(KtTokens.WHERE_KEYWORD, symbol, printer) },
|
{
|
||||||
|
keywordsRenderer.renderKeyword(KtTokens.WHERE_KEYWORD, symbol, printer)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
printer.printCollection(allBounds) { (typeParameter, bound) ->
|
printer.printCollection(allBounds) { (typeParameter, bound) ->
|
||||||
" : ".separated(
|
" : ".separated(
|
||||||
|
|||||||
+3
-1
@@ -20,7 +20,9 @@ public interface KtBackingFieldSymbolRenderer {
|
|||||||
override fun renderSymbol(symbol: KtBackingFieldSymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderSymbol(symbol: KtBackingFieldSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
codeStyle.getSeparatorBetweenAnnotationAndOwner(symbol).separated(
|
codeStyle.getSeparatorBetweenAnnotationAndOwner(symbol).separated(
|
||||||
{ annotationRenderer.renderAnnotations(symbol, printer) },
|
{ annotationRenderer.renderAnnotations(symbol, printer) },
|
||||||
{ keywordRenderer.renderKeyword(KtTokens.FIELD_KEYWORD, symbol, printer) },
|
{
|
||||||
|
keywordsRenderer.renderKeyword(KtTokens.FIELD_KEYWORD, symbol, printer)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -8,8 +8,10 @@ package org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.callab
|
|||||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtDeclarationRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtDeclarationRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||||
|
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtNamedSymbol
|
||||||
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
|
import org.jetbrains.kotlin.renderer.render
|
||||||
|
|
||||||
public interface KtConstructorSymbolRenderer {
|
public interface KtConstructorSymbolRenderer {
|
||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
@@ -22,4 +24,23 @@ public interface KtConstructorSymbolRenderer {
|
|||||||
functionLikeBodyRenderer.renderBody(symbol, printer)
|
functionLikeBodyRenderer.renderBody(symbol, printer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object AS_RAW_SIGNATURE : KtConstructorSymbolRenderer {
|
||||||
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
|
override fun renderSymbol(symbol: KtConstructorSymbol, printer: PrettyPrinter) {
|
||||||
|
printer {
|
||||||
|
" ".separated(
|
||||||
|
{
|
||||||
|
keywordsRenderer.renderKeyword(KtTokens.CONSTRUCTOR_KEYWORD, symbol, printer)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
(symbol.getContainingSymbol() as? KtNamedSymbol)?.name?.let { printer.append(it.render()) }
|
||||||
|
printer.printCollection(symbol.valueParameters, prefix = "(", postfix = ")") {
|
||||||
|
typeRenderer.renderType(it.returnType, printer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+17
@@ -22,4 +22,21 @@ public interface KtFunctionSymbolRenderer {
|
|||||||
functionLikeBodyRenderer.renderBody(symbol, printer)
|
functionLikeBodyRenderer.renderBody(symbol, printer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object AS_RAW_SIGNATURE : KtFunctionSymbolRenderer {
|
||||||
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
|
override fun renderSymbol(symbol: KtFunctionSymbol, printer: PrettyPrinter) {
|
||||||
|
printer {
|
||||||
|
val receiverSymbol = symbol.receiverParameter
|
||||||
|
if (receiverSymbol != null) {
|
||||||
|
withSuffix(".") { callableReceiverRenderer.renderReceiver(receiverSymbol, printer) }
|
||||||
|
}
|
||||||
|
nameRenderer.renderName(symbol, printer)
|
||||||
|
printer.printCollection(symbol.valueParameters, prefix = "(", postfix = ")") {
|
||||||
|
typeRenderer.renderType(it.returnType, printer)
|
||||||
|
}
|
||||||
|
withPrefix(": ") { returnTypeRenderer.renderReturnType(symbol, printer) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+7
-3
@@ -18,7 +18,10 @@ public interface KtNamedClassOrObjectSymbolRenderer {
|
|||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
public fun renderSymbol(symbol: KtNamedClassOrObjectSymbol, printer: PrettyPrinter)
|
public fun renderSymbol(symbol: KtNamedClassOrObjectSymbol, printer: PrettyPrinter)
|
||||||
|
|
||||||
public object AS_SOURCE : KtNamedClassOrObjectSymbolRenderer {
|
public object AS_SOURCE: AsSourceRenderer(true)
|
||||||
|
public object AS_SOURCE_WITHOUT_PRIMARY_CONSTRUCTOR: AsSourceRenderer(false)
|
||||||
|
|
||||||
|
public open class AsSourceRenderer(private val withPrimaryConstructor: Boolean) : KtNamedClassOrObjectSymbolRenderer {
|
||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
override fun renderSymbol(symbol: KtNamedClassOrObjectSymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderSymbol(symbol: KtNamedClassOrObjectSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
val keywords = when (symbol.classKind) {
|
val keywords = when (symbol.classKind) {
|
||||||
@@ -34,9 +37,10 @@ public interface KtNamedClassOrObjectSymbolRenderer {
|
|||||||
" ".separated(
|
" ".separated(
|
||||||
{ renderAnnotationsModifiersAndContextReceivers(symbol, printer, keywords) },
|
{ renderAnnotationsModifiersAndContextReceivers(symbol, printer, keywords) },
|
||||||
{
|
{
|
||||||
val primaryConstructor =
|
val primaryConstructor = if (withPrimaryConstructor)
|
||||||
bodyMemberScopeProvider.getMemberScope(symbol).filterIsInstance<KtConstructorSymbol>()
|
bodyMemberScopeProvider.getMemberScope(symbol).filterIsInstance<KtConstructorSymbol>()
|
||||||
.firstOrNull { it.isPrimary }
|
.firstOrNull { it.isPrimary }
|
||||||
|
else null
|
||||||
|
|
||||||
nameRenderer.renderName(symbol, printer)
|
nameRenderer.renderName(symbol, printer)
|
||||||
typeParametersRenderer.renderTypeParameters(symbol, printer)
|
typeParametersRenderer.renderTypeParameters(symbol, printer)
|
||||||
@@ -44,7 +48,7 @@ public interface KtNamedClassOrObjectSymbolRenderer {
|
|||||||
val annotationsPrinted = checkIfPrinted { renderAnnotationsModifiersAndContextReceivers(primaryConstructor, printer) }
|
val annotationsPrinted = checkIfPrinted { renderAnnotationsModifiersAndContextReceivers(primaryConstructor, printer) }
|
||||||
if (annotationsPrinted) {
|
if (annotationsPrinted) {
|
||||||
withPrefix(" ") {
|
withPrefix(" ") {
|
||||||
keywordRenderer.renderKeyword(KtTokens.CONSTRUCTOR_KEYWORD, primaryConstructor, printer)
|
keywordsRenderer.renderKeyword(KtTokens.CONSTRUCTOR_KEYWORD, primaryConstructor, printer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (primaryConstructor.valueParameters.isNotEmpty()) {
|
if (primaryConstructor.valueParameters.isNotEmpty()) {
|
||||||
|
|||||||
+5
-5
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.analysis.api.renderer.types
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordsRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRendererTypeApproximator
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRendererTypeApproximator
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.types.renderers.*
|
import org.jetbrains.kotlin.analysis.api.renderer.types.renderers.*
|
||||||
@@ -33,7 +33,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
public val typeProjectionRenderer: KtTypeProjectionRenderer,
|
public val typeProjectionRenderer: KtTypeProjectionRenderer,
|
||||||
public val annotationsRenderer: KtAnnotationRenderer,
|
public val annotationsRenderer: KtAnnotationRenderer,
|
||||||
public val contextReceiversRenderer: KtContextReceiversRenderer,
|
public val contextReceiversRenderer: KtContextReceiversRenderer,
|
||||||
public val keywordRenderer: KtKeywordRenderer,
|
public val keywordsRenderer: KtKeywordsRenderer,
|
||||||
) {
|
) {
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
public fun renderType(type: KtType, printer: PrettyPrinter) {
|
public fun renderType(type: KtType, printer: PrettyPrinter) {
|
||||||
@@ -72,7 +72,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
this.typeProjectionRenderer = renderer.typeProjectionRenderer
|
this.typeProjectionRenderer = renderer.typeProjectionRenderer
|
||||||
this.annotationsRenderer = renderer.annotationsRenderer
|
this.annotationsRenderer = renderer.annotationsRenderer
|
||||||
this.contextReceiversRenderer = renderer.contextReceiversRenderer
|
this.contextReceiversRenderer = renderer.contextReceiversRenderer
|
||||||
this.keywordRenderer = renderer.keywordRenderer
|
this.keywordsRenderer = renderer.keywordsRenderer
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
public lateinit var typeProjectionRenderer: KtTypeProjectionRenderer
|
public lateinit var typeProjectionRenderer: KtTypeProjectionRenderer
|
||||||
public lateinit var annotationsRenderer: KtAnnotationRenderer
|
public lateinit var annotationsRenderer: KtAnnotationRenderer
|
||||||
public lateinit var contextReceiversRenderer: KtContextReceiversRenderer
|
public lateinit var contextReceiversRenderer: KtContextReceiversRenderer
|
||||||
public lateinit var keywordRenderer: KtKeywordRenderer
|
public lateinit var keywordsRenderer: KtKeywordsRenderer
|
||||||
|
|
||||||
public fun build(): KtTypeRenderer = KtTypeRenderer(
|
public fun build(): KtTypeRenderer = KtTypeRenderer(
|
||||||
capturedTypeRenderer,
|
capturedTypeRenderer,
|
||||||
@@ -120,7 +120,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
typeProjectionRenderer,
|
typeProjectionRenderer,
|
||||||
annotationsRenderer,
|
annotationsRenderer,
|
||||||
contextReceiversRenderer,
|
contextReceiversRenderer,
|
||||||
keywordRenderer,
|
keywordsRenderer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.renderer.types.impl
|
package org.jetbrains.kotlin.analysis.api.renderer.types.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordsRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KtAnnotationRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRendererForSource
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRendererForSource
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRendererTypeApproximator
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRendererTypeApproximator
|
||||||
@@ -31,7 +31,7 @@ public object KtTypeRendererForSource {
|
|||||||
typeProjectionRenderer = KtTypeProjectionRenderer.WITH_VARIANCE
|
typeProjectionRenderer = KtTypeProjectionRenderer.WITH_VARIANCE
|
||||||
annotationsRenderer = KtAnnotationRendererForSource.WITH_QUALIFIED_NAMES
|
annotationsRenderer = KtAnnotationRendererForSource.WITH_QUALIFIED_NAMES
|
||||||
contextReceiversRenderer = KtContextReceiversRendererForSource.WITH_LABELS
|
contextReceiversRenderer = KtContextReceiversRendererForSource.WITH_LABELS
|
||||||
keywordRenderer = KtKeywordRenderer.AS_WORD
|
keywordsRenderer = KtKeywordsRenderer.AS_WORD
|
||||||
}
|
}
|
||||||
|
|
||||||
public val WITH_SHORT_NAMES: KtTypeRenderer = WITH_QUALIFIED_NAMES.with {
|
public val WITH_SHORT_NAMES: KtTypeRenderer = WITH_QUALIFIED_NAMES.with {
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public interface KtDynamicTypeRenderer {
|
|||||||
public object AS_DYNAMIC_WORD : KtDynamicTypeRenderer {
|
public object AS_DYNAMIC_WORD : KtDynamicTypeRenderer {
|
||||||
context(KtAnalysisSession, KtTypeRenderer)
|
context(KtAnalysisSession, KtTypeRenderer)
|
||||||
override fun renderType(type: KtDynamicType, printer: PrettyPrinter) {
|
override fun renderType(type: KtDynamicType, printer: PrettyPrinter) {
|
||||||
keywordRenderer.renderKeyword(KtTokens.DYNAMIC_KEYWORD, type, printer)
|
keywordsRenderer.renderKeyword(KtTokens.DYNAMIC_KEYWORD, type, printer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ public interface KtFunctionalTypeRenderer {
|
|||||||
" ".separated(
|
" ".separated(
|
||||||
{
|
{
|
||||||
if (type.isSuspend) {
|
if (type.isSuspend) {
|
||||||
keywordRenderer.renderKeyword(KtTokens.SUSPEND_KEYWORD, type, printer)
|
keywordsRenderer.renderKeyword(KtTokens.SUSPEND_KEYWORD, type, printer)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -65,7 +65,7 @@ public interface KtFunctionalTypeRenderer {
|
|||||||
|
|
||||||
public object AS_CLASS_TYPE_FOR_REFLECTION_TYPES : KtFunctionalTypeRenderer {
|
public object AS_CLASS_TYPE_FOR_REFLECTION_TYPES : KtFunctionalTypeRenderer {
|
||||||
context(KtAnalysisSession, KtTypeRenderer)
|
context(KtAnalysisSession, KtTypeRenderer)
|
||||||
override fun renderType(type: KtFunctionalType, printer: PrettyPrinter): Unit {
|
override fun renderType(type: KtFunctionalType, printer: PrettyPrinter) {
|
||||||
val renderer = if (type.isReflectType) AS_CLASS_TYPE else AS_FUNCTIONAL_TYPE
|
val renderer = if (type.isReflectType) AS_CLASS_TYPE else AS_FUNCTIONAL_TYPE
|
||||||
renderer.renderType(type, printer)
|
renderer.renderType(type, printer)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user