[AA] KT-55098 Render context receivers in declarations & function types
- `context(...)` is a modifier that must precede annotations and other modifiers, so for declarations it is rendered in `renderAnnotationsAndModifiers`. - Ignore `@ContextFunctionTypeParams` in the annotation list of FE10 types, as the annotation is an implementation detail of context receivers in K1 and shouldn't be rendered. ^KT-55098 fixed
This commit is contained in:
committed by
Space Team
parent
e2804693bf
commit
2cd16f055a
+4
-1
@@ -28,7 +28,10 @@ interface KtFe10Type : KtLifetimeOwner, KtAnnotated {
|
|||||||
KtFe10AnnotationsList.create(
|
KtFe10AnnotationsList.create(
|
||||||
type.annotations,
|
type.annotations,
|
||||||
token,
|
token,
|
||||||
ignoreAnnotations = setOf(StandardClassIds.Annotations.ExtensionFunctionType)
|
ignoreAnnotations = setOf(
|
||||||
|
StandardClassIds.Annotations.ExtensionFunctionType,
|
||||||
|
StandardClassIds.Annotations.ContextFunctionTypeParams,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
@@ -70,6 +70,12 @@ public class Fe10IdeNormalAnalysisSourceModuleRendererTestGenerated extends Abst
|
|||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextReceiver.kt")
|
||||||
|
public void testContextReceiver() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/contextReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("delegates.kt")
|
@TestMetadata("delegates.kt")
|
||||||
public void testDelegates() throws Exception {
|
public void testDelegates() throws Exception {
|
||||||
@@ -228,5 +234,11 @@ public class Fe10IdeNormalAnalysisSourceModuleRendererTestGenerated extends Abst
|
|||||||
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextFunctionTypes.kt")
|
||||||
|
public void testContextFunctionTypes() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/contextFunctionTypes.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -70,6 +70,12 @@ public class FirIdeDependentAnalysisSourceModuleRendererTestGenerated extends Ab
|
|||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextReceiver.kt")
|
||||||
|
public void testContextReceiver() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/contextReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("delegates.kt")
|
@TestMetadata("delegates.kt")
|
||||||
public void testDelegates() throws Exception {
|
public void testDelegates() throws Exception {
|
||||||
@@ -228,5 +234,11 @@ public class FirIdeDependentAnalysisSourceModuleRendererTestGenerated extends Ab
|
|||||||
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextFunctionTypes.kt")
|
||||||
|
public void testContextFunctionTypes() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/contextFunctionTypes.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -70,6 +70,12 @@ public class FirIdeNormalAnalysisSourceModuleRendererTestGenerated extends Abstr
|
|||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextReceiver.kt")
|
||||||
|
public void testContextReceiver() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/contextReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("delegates.kt")
|
@TestMetadata("delegates.kt")
|
||||||
public void testDelegates() throws Exception {
|
public void testDelegates() throws Exception {
|
||||||
@@ -228,5 +234,11 @@ public class FirIdeNormalAnalysisSourceModuleRendererTestGenerated extends Abstr
|
|||||||
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextFunctionTypes.kt")
|
||||||
|
public void testContextFunctionTypes() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/contextFunctionTypes.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -70,6 +70,12 @@ public class FirStandaloneNormalAnalysisSourceModuleRendererTestGenerated extend
|
|||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/constructorOfAnonymousObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextReceiver.kt")
|
||||||
|
public void testContextReceiver() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/contextReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("delegates.kt")
|
@TestMetadata("delegates.kt")
|
||||||
public void testDelegates() throws Exception {
|
public void testDelegates() throws Exception {
|
||||||
@@ -228,5 +234,11 @@ public class FirStandaloneNormalAnalysisSourceModuleRendererTestGenerated extend
|
|||||||
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
public void testAnnotationOnTypesWithComplexExpression() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/annotationOnTypesWithComplexExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("contextFunctionTypes.kt")
|
||||||
|
public void testContextFunctionTypes() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/types/contextFunctionTypes.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.base.contextReceivers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
|
import org.jetbrains.kotlin.analysis.api.base.KtContextReceiversOwner
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.renderers.KtContextReceiverLabelRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.renderers.KtContextReceiverListRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.types.KtTypeRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
|
|
||||||
|
public class KtContextReceiversRenderer(
|
||||||
|
public val contextReceiverListRenderer: KtContextReceiverListRenderer,
|
||||||
|
public val contextReceiverLabelRenderer: KtContextReceiverLabelRenderer,
|
||||||
|
) {
|
||||||
|
context(KtAnalysisSession, KtTypeRenderer)
|
||||||
|
public fun renderContextReceivers(owner: KtContextReceiversOwner, printer: PrettyPrinter) {
|
||||||
|
contextReceiverListRenderer.renderContextReceivers(owner, printer)
|
||||||
|
}
|
||||||
|
|
||||||
|
public inline fun with(action: Builder.() -> Unit): KtContextReceiversRenderer {
|
||||||
|
val renderer = this
|
||||||
|
return KtContextReceiversRenderer {
|
||||||
|
this.contextReceiverListRenderer = renderer.contextReceiverListRenderer
|
||||||
|
this.contextReceiverLabelRenderer = renderer.contextReceiverLabelRenderer
|
||||||
|
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Builder {
|
||||||
|
public lateinit var contextReceiverListRenderer: KtContextReceiverListRenderer
|
||||||
|
public lateinit var contextReceiverLabelRenderer: KtContextReceiverLabelRenderer
|
||||||
|
|
||||||
|
public fun build(): KtContextReceiversRenderer = KtContextReceiversRenderer(
|
||||||
|
contextReceiverListRenderer,
|
||||||
|
contextReceiverLabelRenderer,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
public inline operator fun invoke(action: Builder.() -> Unit): KtContextReceiversRenderer =
|
||||||
|
Builder().apply(action).build()
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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.base.contextReceivers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.renderers.KtContextReceiverLabelRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.renderers.KtContextReceiverListRenderer
|
||||||
|
|
||||||
|
public object KtContextReceiversRendererForSource {
|
||||||
|
public val WITH_LABELS: KtContextReceiversRenderer = KtContextReceiversRenderer {
|
||||||
|
contextReceiverListRenderer = KtContextReceiverListRenderer.AS_SOURCE
|
||||||
|
contextReceiverLabelRenderer = KtContextReceiverLabelRenderer.WITH_LABEL
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.base.contextReceivers.renderers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
|
import org.jetbrains.kotlin.analysis.api.base.KtContextReceiver
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
|
import org.jetbrains.kotlin.renderer.render
|
||||||
|
|
||||||
|
public interface KtContextReceiverLabelRenderer {
|
||||||
|
context(KtAnalysisSession, KtContextReceiversRenderer)
|
||||||
|
public fun renderLabel(contextReceiver: KtContextReceiver, printer: PrettyPrinter)
|
||||||
|
|
||||||
|
public object WITH_LABEL : KtContextReceiverLabelRenderer {
|
||||||
|
context(KtAnalysisSession, KtContextReceiversRenderer)
|
||||||
|
override fun renderLabel(contextReceiver: KtContextReceiver, printer: PrettyPrinter): Unit = printer {
|
||||||
|
val label = contextReceiver.label ?: return@printer
|
||||||
|
append(label.render())
|
||||||
|
append('@')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.base.contextReceivers.renderers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||||
|
import org.jetbrains.kotlin.analysis.api.base.KtContextReceiversOwner
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.base.contextReceivers.KtContextReceiversRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.api.renderer.types.KtTypeRenderer
|
||||||
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
|
|
||||||
|
public interface KtContextReceiverListRenderer {
|
||||||
|
context(KtAnalysisSession, KtContextReceiversRenderer, KtTypeRenderer)
|
||||||
|
public fun renderContextReceivers(owner: KtContextReceiversOwner, printer: PrettyPrinter)
|
||||||
|
|
||||||
|
public object AS_SOURCE : KtContextReceiverListRenderer {
|
||||||
|
context(KtAnalysisSession, KtContextReceiversRenderer, KtTypeRenderer)
|
||||||
|
override fun renderContextReceivers(owner: KtContextReceiversOwner, printer: PrettyPrinter) {
|
||||||
|
val contextReceivers = owner.contextReceivers
|
||||||
|
if (contextReceivers.isEmpty()) return
|
||||||
|
|
||||||
|
printer {
|
||||||
|
append("context(")
|
||||||
|
printCollection(contextReceivers) { contextReceiver ->
|
||||||
|
contextReceiverLabelRenderer.renderLabel(contextReceiver, printer)
|
||||||
|
renderType(contextReceiver.type, printer)
|
||||||
|
}
|
||||||
|
append(")")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -8,6 +8,7 @@ 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.KtKeywordRenderer
|
||||||
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.declarations.bodies.*
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.bodies.*
|
||||||
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.renderers.*
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.*
|
||||||
@@ -27,6 +28,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 keywordRenderer: KtKeywordRenderer,
|
||||||
|
public val contextReceiversRenderer: KtContextReceiversRenderer,
|
||||||
public val codeStyle: KtRendererCodeStyle,
|
public val codeStyle: KtRendererCodeStyle,
|
||||||
public val typeRenderer: KtTypeRenderer,
|
public val typeRenderer: KtTypeRenderer,
|
||||||
public val annotationRenderer: KtAnnotationRenderer,
|
public val annotationRenderer: KtAnnotationRenderer,
|
||||||
@@ -110,6 +112,7 @@ public class KtDeclarationRenderer private constructor(
|
|||||||
return KtDeclarationRenderer {
|
return KtDeclarationRenderer {
|
||||||
this.nameRenderer = renderer.nameRenderer
|
this.nameRenderer = renderer.nameRenderer
|
||||||
this.keywordRender = renderer.keywordRenderer
|
this.keywordRender = renderer.keywordRenderer
|
||||||
|
this.contextReceiversRenderer = renderer.contextReceiversRenderer
|
||||||
this.codeStyle = renderer.codeStyle
|
this.codeStyle = renderer.codeStyle
|
||||||
this.typeRenderer = renderer.typeRenderer
|
this.typeRenderer = renderer.typeRenderer
|
||||||
this.annotationRenderer = renderer.annotationRenderer
|
this.annotationRenderer = renderer.annotationRenderer
|
||||||
@@ -174,6 +177,7 @@ public class KtDeclarationRenderer private constructor(
|
|||||||
public open class Builder {
|
public open class Builder {
|
||||||
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 keywordRender: KtKeywordRenderer
|
public lateinit var keywordRender: KtKeywordRenderer
|
||||||
public lateinit var codeStyle: KtRendererCodeStyle
|
public lateinit var codeStyle: KtRendererCodeStyle
|
||||||
public lateinit var typeRenderer: KtTypeRenderer
|
public lateinit var typeRenderer: KtTypeRenderer
|
||||||
@@ -229,6 +233,7 @@ public class KtDeclarationRenderer private constructor(
|
|||||||
public fun build(): KtDeclarationRenderer = KtDeclarationRenderer(
|
public fun build(): KtDeclarationRenderer = KtDeclarationRenderer(
|
||||||
nameRenderer,
|
nameRenderer,
|
||||||
keywordRender,
|
keywordRender,
|
||||||
|
contextReceiversRenderer,
|
||||||
codeStyle,
|
codeStyle,
|
||||||
typeRenderer,
|
typeRenderer,
|
||||||
annotationRenderer,
|
annotationRenderer,
|
||||||
|
|||||||
+10
-6
@@ -17,6 +17,9 @@ public interface KtRendererCodeStyle {
|
|||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
public fun getIndentSize(): Int
|
public fun getIndentSize(): Int
|
||||||
|
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
public fun getSeparatorAfterContextReceivers(): String
|
||||||
|
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
public fun getSeparatorBetweenAnnotationAndOwner(symbol: KtAnnotated): String
|
public fun getSeparatorBetweenAnnotationAndOwner(symbol: KtAnnotated): String
|
||||||
|
|
||||||
@@ -31,9 +34,11 @@ public interface KtRendererCodeStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public object KtRecommendedRendererCodeStyle : KtRendererCodeStyle {
|
public object KtRecommendedRendererCodeStyle : KtRendererCodeStyle {
|
||||||
context(KtAnalysisSession) override fun getIndentSize(): Int {
|
context(KtAnalysisSession)
|
||||||
return 4
|
override fun getIndentSize(): Int = 4
|
||||||
}
|
|
||||||
|
context(KtAnalysisSession)
|
||||||
|
override fun getSeparatorAfterContextReceivers(): String = "\n"
|
||||||
|
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
override fun getSeparatorBetweenAnnotationAndOwner(symbol: KtAnnotated): String {
|
override fun getSeparatorBetweenAnnotationAndOwner(symbol: KtAnnotated): String {
|
||||||
@@ -55,9 +60,8 @@ public object KtRecommendedRendererCodeStyle : KtRendererCodeStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context(KtAnalysisSession) override fun getSeparatorBetweenModifiers(): String {
|
context(KtAnalysisSession)
|
||||||
return " "
|
override fun getSeparatorBetweenModifiers(): String = " "
|
||||||
}
|
|
||||||
|
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
override fun getSeparatorBetweenMembers(first: KtDeclarationSymbol, second: KtDeclarationSymbol): String {
|
override fun getSeparatorBetweenMembers(first: KtDeclarationSymbol, second: KtDeclarationSymbol): String {
|
||||||
|
|||||||
+2
-1
@@ -7,6 +7,7 @@ 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.KtKeywordRenderer
|
||||||
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.declarations.KtCallableReturnTypeFilter
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtCallableReturnTypeFilter
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtDeclarationRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtDeclarationRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRecommendedRendererCodeStyle
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRecommendedRendererCodeStyle
|
||||||
@@ -29,6 +30,7 @@ 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
|
keywordRender = KtKeywordRenderer.AS_WORD
|
||||||
|
contextReceiversRenderer = KtContextReceiversRendererForSource.WITH_LABELS
|
||||||
codeStyle = KtRecommendedRendererCodeStyle
|
codeStyle = KtRecommendedRendererCodeStyle
|
||||||
modifiersRenderer = KtDeclarationModifiersRendererForSource.NO_IMPLICIT_MODIFIERS
|
modifiersRenderer = KtDeclarationModifiersRendererForSource.NO_IMPLICIT_MODIFIERS
|
||||||
classifierBodyRenderer = KtClassifierBodyRenderer.NO_BODY
|
classifierBodyRenderer = KtClassifierBodyRenderer.NO_BODY
|
||||||
@@ -87,4 +89,3 @@ public object KtDeclarationRendererForSource {
|
|||||||
typeRenderer = KtTypeRendererForSource.WITH_SHORT_NAMES
|
typeRenderer = KtTypeRendererForSource.WITH_SHORT_NAMES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-6
@@ -7,25 +7,28 @@ 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.annotations.KtAnnotated
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotated
|
||||||
|
import org.jetbrains.kotlin.analysis.api.base.KtContextReceiversOwner
|
||||||
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
|
||||||
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
||||||
|
|
||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
public fun <S> renderAnnotationsAndModifiers(
|
public fun <S> renderAnnotationsModifiersAndContextReceivers(
|
||||||
symbol: S,
|
symbol: S,
|
||||||
printer: PrettyPrinter,
|
printer: PrettyPrinter,
|
||||||
keyword: KtKeywordToken,
|
keyword: KtKeywordToken,
|
||||||
): Unit where S : KtAnnotated, S : KtDeclarationSymbol = printer {
|
): Unit where S : KtAnnotated, S : KtDeclarationSymbol = printer {
|
||||||
renderAnnotationsAndModifiers(symbol, printer, listOf(keyword))
|
renderAnnotationsModifiersAndContextReceivers(symbol, printer, listOf(keyword))
|
||||||
}
|
}
|
||||||
|
|
||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
public fun <S> renderAnnotationsAndModifiers(
|
public fun <S> renderAnnotationsModifiersAndContextReceivers(
|
||||||
symbol: S,
|
symbol: S,
|
||||||
printer: PrettyPrinter,
|
printer: PrettyPrinter,
|
||||||
keywords: List<KtKeywordToken>,
|
keywords: List<KtKeywordToken>,
|
||||||
): Unit where S : KtAnnotated, S : KtDeclarationSymbol = printer {
|
): Unit where S : KtAnnotated, S : KtDeclarationSymbol = printer {
|
||||||
|
renderContextReceivers(symbol, printer)
|
||||||
|
|
||||||
val annotationsRendered: Boolean
|
val annotationsRendered: Boolean
|
||||||
val modifiersRendered: Boolean
|
val modifiersRendered: Boolean
|
||||||
codeStyle.getSeparatorBetweenAnnotationAndOwner(symbol).separated(
|
codeStyle.getSeparatorBetweenAnnotationAndOwner(symbol).separated(
|
||||||
@@ -43,14 +46,25 @@ public fun <S> renderAnnotationsAndModifiers(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
public fun <S> renderAnnotationsAndModifiers(
|
public fun <S> renderAnnotationsModifiersAndContextReceivers(
|
||||||
symbol: S,
|
symbol: S,
|
||||||
printer: PrettyPrinter,
|
printer: PrettyPrinter,
|
||||||
): Unit where S : KtAnnotated, S : KtDeclarationSymbol = printer {
|
): Unit where S : KtAnnotated, S : KtDeclarationSymbol = printer {
|
||||||
|
renderContextReceivers(symbol, printer)
|
||||||
codeStyle.getSeparatorBetweenAnnotationAndOwner(symbol).separated(
|
codeStyle.getSeparatorBetweenAnnotationAndOwner(symbol).separated(
|
||||||
{ annotationRenderer.renderAnnotations(symbol, printer) },
|
{ annotationRenderer.renderAnnotations(symbol, printer) },
|
||||||
{ modifiersRenderer.renderDeclarationModifiers(symbol, printer) }
|
{ modifiersRenderer.renderDeclarationModifiers(symbol, printer) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
|
private fun renderContextReceivers(symbol: KtDeclarationSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
|
if (symbol !is KtContextReceiversOwner) return
|
||||||
|
|
||||||
|
with(typeRenderer) {
|
||||||
|
withSuffix(codeStyle.getSeparatorAfterContextReceivers()) {
|
||||||
|
contextReceiversRenderer.renderContextReceivers(symbol, printer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@ 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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtNamedSymbol
|
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
|
||||||
@@ -22,8 +22,8 @@ public interface KtCallableSignatureRenderer {
|
|||||||
override fun renderCallableSignature(symbol: KtCallableSymbol, keyword: KtKeywordToken?, printer: PrettyPrinter): Unit = printer {
|
override fun renderCallableSignature(symbol: KtCallableSymbol, keyword: KtKeywordToken?, printer: PrettyPrinter): Unit = printer {
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{
|
{
|
||||||
if (keyword != null) renderAnnotationsAndModifiers(symbol, printer, keyword)
|
if (keyword != null) renderAnnotationsModifiersAndContextReceivers(symbol, printer, keyword)
|
||||||
else renderAnnotationsAndModifiers(symbol, printer)
|
else renderAnnotationsModifiersAndContextReceivers(symbol, printer)
|
||||||
},
|
},
|
||||||
{ typeParametersRenderer.renderTypeParameters(symbol, printer) },
|
{ typeParametersRenderer.renderTypeParameters(symbol, printer) },
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ 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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtEnumEntrySymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtEnumEntrySymbol
|
||||||
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ public interface KtEnumEntrySymbolRenderer {
|
|||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
override fun renderSymbol(symbol: KtEnumEntrySymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderSymbol(symbol: KtEnumEntrySymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{ renderAnnotationsAndModifiers(symbol, printer) },
|
{ renderAnnotationsModifiersAndContextReceivers(symbol, printer) },
|
||||||
{ nameRenderer.renderName(symbol, printer) },
|
{ nameRenderer.renderName(symbol, printer) },
|
||||||
{ classifierBodyRenderer.renderBody(symbol, printer) },
|
{ classifierBodyRenderer.renderBody(symbol, printer) },
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ 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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtPropertyGetterSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtPropertyGetterSymbol
|
||||||
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
|
||||||
@@ -21,7 +21,7 @@ public interface KtPropertyGetterSymbolRenderer {
|
|||||||
override fun renderSymbol(symbol: KtPropertyGetterSymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderSymbol(symbol: KtPropertyGetterSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{
|
{
|
||||||
renderAnnotationsAndModifiers(symbol, printer, KtTokens.GET_KEYWORD)
|
renderAnnotationsModifiersAndContextReceivers(symbol, printer, KtTokens.GET_KEYWORD)
|
||||||
valueParametersRenderer.renderValueParameters(symbol, printer)
|
valueParametersRenderer.renderValueParameters(symbol, printer)
|
||||||
},
|
},
|
||||||
{ accessorBodyRenderer.renderBody(symbol, printer) },
|
{ accessorBodyRenderer.renderBody(symbol, printer) },
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ 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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtPropertySetterSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtPropertySetterSymbol
|
||||||
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
|
||||||
@@ -21,7 +21,7 @@ public interface KtPropertySetterSymbolRenderer {
|
|||||||
override fun renderSymbol(symbol: KtPropertySetterSymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderSymbol(symbol: KtPropertySetterSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{
|
{
|
||||||
renderAnnotationsAndModifiers(symbol, printer, KtTokens.SET_KEYWORD)
|
renderAnnotationsModifiersAndContextReceivers(symbol, printer, KtTokens.SET_KEYWORD)
|
||||||
valueParametersRenderer.renderValueParameters(symbol, printer)
|
valueParametersRenderer.renderValueParameters(symbol, printer)
|
||||||
},
|
},
|
||||||
{ accessorBodyRenderer.renderBody(symbol, printer) },
|
{ accessorBodyRenderer.renderBody(symbol, printer) },
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.classi
|
|||||||
|
|
||||||
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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtAnonymousObjectSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtAnonymousObjectSymbol
|
||||||
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
|
||||||
@@ -22,7 +22,7 @@ public interface KtAnonymousObjectSymbolRenderer {
|
|||||||
" ".separated(
|
" ".separated(
|
||||||
{
|
{
|
||||||
" : ".separated(
|
" : ".separated(
|
||||||
{ renderAnnotationsAndModifiers(symbol, printer, KtTokens.OBJECT_KEYWORD) },
|
{ renderAnnotationsModifiersAndContextReceivers(symbol, printer, KtTokens.OBJECT_KEYWORD) },
|
||||||
{ superTypeListRenderer.renderSuperTypes(symbol, printer) }
|
{ superTypeListRenderer.renderSuperTypes(symbol, printer) }
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.classi
|
|||||||
|
|
||||||
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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassKind
|
import org.jetbrains.kotlin.analysis.api.symbols.KtClassKind
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol
|
||||||
@@ -32,7 +32,7 @@ public interface KtNamedClassOrObjectSymbolRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{ renderAnnotationsAndModifiers(symbol, printer, keywords) },
|
{ renderAnnotationsModifiersAndContextReceivers(symbol, printer, keywords) },
|
||||||
{
|
{
|
||||||
val primaryConstructor =
|
val primaryConstructor =
|
||||||
bodyMemberScopeProvider.getMemberScope(symbol).filterIsInstance<KtConstructorSymbol>()
|
bodyMemberScopeProvider.getMemberScope(symbol).filterIsInstance<KtConstructorSymbol>()
|
||||||
@@ -41,7 +41,7 @@ public interface KtNamedClassOrObjectSymbolRenderer {
|
|||||||
nameRenderer.renderName(symbol, printer)
|
nameRenderer.renderName(symbol, printer)
|
||||||
typeParametersRenderer.renderTypeParameters(symbol, printer)
|
typeParametersRenderer.renderTypeParameters(symbol, printer)
|
||||||
if (primaryConstructor != null) {
|
if (primaryConstructor != null) {
|
||||||
val annotationsPrinted = checkIfPrinted { renderAnnotationsAndModifiers(primaryConstructor, printer) }
|
val annotationsPrinted = checkIfPrinted { renderAnnotationsModifiersAndContextReceivers(primaryConstructor, printer) }
|
||||||
if (annotationsPrinted) {
|
if (annotationsPrinted) {
|
||||||
withPrefix(" ") {
|
withPrefix(" ") {
|
||||||
keywordRenderer.renderKeyword(KtTokens.CONSTRUCTOR_KEYWORD, primaryConstructor, printer)
|
keywordRenderer.renderKeyword(KtTokens.CONSTRUCTOR_KEYWORD, primaryConstructor, printer)
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.classi
|
|||||||
|
|
||||||
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.renderer.declarations.renderAnnotationsAndModifiers
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderAnnotationsModifiersAndContextReceivers
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtTypeAliasSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtTypeAliasSymbol
|
||||||
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
|
||||||
@@ -20,7 +20,7 @@ public interface KtTypeAliasSymbolRenderer {
|
|||||||
context(KtAnalysisSession, KtDeclarationRenderer)
|
context(KtAnalysisSession, KtDeclarationRenderer)
|
||||||
override fun renderSymbol(symbol: KtTypeAliasSymbol, printer: PrettyPrinter): Unit = printer {
|
override fun renderSymbol(symbol: KtTypeAliasSymbol, printer: PrettyPrinter): Unit = printer {
|
||||||
" ".separated(
|
" ".separated(
|
||||||
{ renderAnnotationsAndModifiers(symbol, printer, KtTokens.TYPE_ALIAS_KEYWORD) },
|
{ renderAnnotationsModifiersAndContextReceivers(symbol, printer, KtTokens.TYPE_ALIAS_KEYWORD) },
|
||||||
{
|
{
|
||||||
" = ".separated(
|
" = ".separated(
|
||||||
{
|
{
|
||||||
|
|||||||
+5
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.analysis.api.renderer.types
|
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.KtKeywordRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.base.KtKeywordRenderer
|
||||||
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
|
||||||
@@ -31,6 +32,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
public val typeApproximator: KtRendererTypeApproximator,
|
public val typeApproximator: KtRendererTypeApproximator,
|
||||||
public val typeProjectionRenderer: KtTypeProjectionRenderer,
|
public val typeProjectionRenderer: KtTypeProjectionRenderer,
|
||||||
public val annotationsRenderer: KtAnnotationRenderer,
|
public val annotationsRenderer: KtAnnotationRenderer,
|
||||||
|
public val contextReceiversRenderer: KtContextReceiversRenderer,
|
||||||
public val keywordRenderer: KtKeywordRenderer,
|
public val keywordRenderer: KtKeywordRenderer,
|
||||||
) {
|
) {
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
@@ -69,6 +71,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
this.typeApproximator = renderer.typeApproximator
|
this.typeApproximator = renderer.typeApproximator
|
||||||
this.typeProjectionRenderer = renderer.typeProjectionRenderer
|
this.typeProjectionRenderer = renderer.typeProjectionRenderer
|
||||||
this.annotationsRenderer = renderer.annotationsRenderer
|
this.annotationsRenderer = renderer.annotationsRenderer
|
||||||
|
this.contextReceiversRenderer = renderer.contextReceiversRenderer
|
||||||
this.keywordRenderer = renderer.keywordRenderer
|
this.keywordRenderer = renderer.keywordRenderer
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
@@ -96,6 +99,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
public lateinit var typeApproximator: KtRendererTypeApproximator
|
public lateinit var typeApproximator: KtRendererTypeApproximator
|
||||||
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 keywordRenderer: KtKeywordRenderer
|
public lateinit var keywordRenderer: KtKeywordRenderer
|
||||||
|
|
||||||
public fun build(): KtTypeRenderer = KtTypeRenderer(
|
public fun build(): KtTypeRenderer = KtTypeRenderer(
|
||||||
@@ -115,6 +119,7 @@ public class KtTypeRenderer private constructor(
|
|||||||
typeApproximator,
|
typeApproximator,
|
||||||
typeProjectionRenderer,
|
typeProjectionRenderer,
|
||||||
annotationsRenderer,
|
annotationsRenderer,
|
||||||
|
contextReceiversRenderer,
|
||||||
keywordRenderer,
|
keywordRenderer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -7,6 +7,7 @@ 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.KtKeywordRenderer
|
||||||
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.declarations.KtRendererTypeApproximator
|
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KtRendererTypeApproximator
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.types.KtTypeRenderer
|
import org.jetbrains.kotlin.analysis.api.renderer.types.KtTypeRenderer
|
||||||
import org.jetbrains.kotlin.analysis.api.renderer.types.renderers.*
|
import org.jetbrains.kotlin.analysis.api.renderer.types.renderers.*
|
||||||
@@ -29,6 +30,7 @@ public object KtTypeRendererForSource {
|
|||||||
typeApproximator = KtRendererTypeApproximator.TO_DENNOTABLE
|
typeApproximator = KtRendererTypeApproximator.TO_DENNOTABLE
|
||||||
typeProjectionRenderer = KtTypeProjectionRenderer.WITH_VARIANCE
|
typeProjectionRenderer = KtTypeProjectionRenderer.WITH_VARIANCE
|
||||||
annotationsRenderer = KtAnnotationRendererForSource.WITH_QUALIFIED_NAMES
|
annotationsRenderer = KtAnnotationRendererForSource.WITH_QUALIFIED_NAMES
|
||||||
|
contextReceiversRenderer = KtContextReceiversRendererForSource.WITH_LABELS
|
||||||
keywordRenderer = KtKeywordRenderer.AS_WORD
|
keywordRenderer = KtKeywordRenderer.AS_WORD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -24,6 +24,11 @@ public interface KtFunctionalTypeRenderer {
|
|||||||
if (annotationsRendered) printer.append(" ")
|
if (annotationsRendered) printer.append(" ")
|
||||||
if (annotationsRendered || type.nullability == KtTypeNullability.NULLABLE) append("(")
|
if (annotationsRendered || type.nullability == KtTypeNullability.NULLABLE) append("(")
|
||||||
" ".separated(
|
" ".separated(
|
||||||
|
{
|
||||||
|
if (type.hasContextReceivers) {
|
||||||
|
contextReceiversRenderer.renderContextReceivers(type, printer)
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
if (type.isSuspend) {
|
if (type.isSuspend) {
|
||||||
keywordRenderer.renderKeyword(KtTokens.SUSPEND_KEYWORD, type, printer)
|
keywordRenderer.renderKeyword(KtTokens.SUSPEND_KEYWORD, type, printer)
|
||||||
|
|||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
interface Context1
|
||||||
|
|
||||||
|
interface Context2<A> {
|
||||||
|
fun getContextElement(): A
|
||||||
|
}
|
||||||
|
|
||||||
|
class Context2Impl<A>(value: A) : Context2<A> {
|
||||||
|
override fun getContextElement(): A
|
||||||
|
|
||||||
|
val value: A
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Int, String)
|
||||||
|
class A {
|
||||||
|
constructor(int: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context1, c2@Context2<String>)
|
||||||
|
class B {
|
||||||
|
override fun toString(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context2<A>)
|
||||||
|
class C<A> {
|
||||||
|
val a: A
|
||||||
|
get()
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context1)
|
||||||
|
@Deprecated(message = "Use `B` instead.")
|
||||||
|
class D
|
||||||
|
|
||||||
|
context(b@B, `fun`@A)
|
||||||
|
fun foo()
|
||||||
|
|
||||||
|
context(Context2<C<String>>)
|
||||||
|
fun bar(): ERROR
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
interface Context1
|
||||||
|
|
||||||
|
interface Context2<A> {
|
||||||
|
fun getContextElement(): A
|
||||||
|
}
|
||||||
|
|
||||||
|
class Context2Impl<A>(val value: A) : Context2<A> {
|
||||||
|
override fun getContextElement(): A = value
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Int, String)
|
||||||
|
class A {
|
||||||
|
context(Double)
|
||||||
|
constructor(int: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context1, c2@Context2<String>)
|
||||||
|
class B {
|
||||||
|
override fun toString(): String = getContextElement()
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context2<A>)
|
||||||
|
class C<A> {
|
||||||
|
val a: A
|
||||||
|
get() = getContextElement()
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context1)
|
||||||
|
@Deprecated("Use `B` instead.")
|
||||||
|
class D
|
||||||
|
|
||||||
|
context(b@B, `fun`@A)
|
||||||
|
fun foo() = Unit
|
||||||
|
|
||||||
|
context(Context2<C<String>>)
|
||||||
|
fun bar() = with (Context2Impl(getContextElement().a)) { C() }
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
interface Context1
|
||||||
|
|
||||||
|
interface Context2<A> {
|
||||||
|
fun getContextElement(): A
|
||||||
|
}
|
||||||
|
|
||||||
|
class Context2Impl<A>(value: A) : Context2<A> {
|
||||||
|
override fun getContextElement(): A
|
||||||
|
|
||||||
|
val value: A
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Int, String)
|
||||||
|
class A {
|
||||||
|
constructor(int: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context1, c2@Context2<String>)
|
||||||
|
class B {
|
||||||
|
override fun toString(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context2<A>)
|
||||||
|
class C<A> {
|
||||||
|
val a: A
|
||||||
|
get()
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Context1)
|
||||||
|
@Deprecated(message = "Use `B` instead.")
|
||||||
|
class D
|
||||||
|
|
||||||
|
context(b@B, `fun`@A)
|
||||||
|
fun foo()
|
||||||
|
|
||||||
|
context(Context2<C<String>>)
|
||||||
|
fun bar(): C<String>
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
interface A
|
||||||
|
interface B
|
||||||
|
|
||||||
|
val f1: context(A) () -> Unit = { }
|
||||||
|
|
||||||
|
val f2: context(B, A) Int.() -> Unit = { }
|
||||||
|
|
||||||
|
val f3: (Int) -> (context(A) (String) -> String) = { { "" } }
|
||||||
|
|
||||||
|
val f4: (context(A) B.(Int) -> Unit) -> (context(B) (Int) -> Unit) = { { } }
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
interface A
|
||||||
|
|
||||||
|
interface B
|
||||||
|
|
||||||
|
val f1: context(A) () -> Unit
|
||||||
|
|
||||||
|
val f2: context(B, A) Int.() -> Unit
|
||||||
|
|
||||||
|
val f3: (Int) -> context(A) (String) -> String
|
||||||
|
|
||||||
|
val f4: (context(A) B.(Int) -> Unit) -> context(B) (Int) -> Unit
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
context(kotlin.Int, s@kotlin.String)
|
||||||
class A {
|
class A {
|
||||||
constructor(int: kotlin.Int)
|
constructor(int: kotlin.Int)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1 +1,2 @@
|
|||||||
|
context(kotlin.Int, s@kotlin.String)
|
||||||
fun y()
|
fun y()
|
||||||
|
|||||||
+1
@@ -1,2 +1,3 @@
|
|||||||
|
context(kotlin.Int, s@kotlin.String)
|
||||||
val y: kotlin.Int
|
val y: kotlin.Int
|
||||||
get()
|
get()
|
||||||
Vendored
+4
@@ -1,9 +1,13 @@
|
|||||||
|
context(A)
|
||||||
fun tooo()
|
fun tooo()
|
||||||
|
|
||||||
|
context(B)
|
||||||
fun tooo()
|
fun tooo()
|
||||||
|
|
||||||
|
context(A, B)
|
||||||
fun tooo()
|
fun tooo()
|
||||||
|
|
||||||
|
context(B, A)
|
||||||
fun tooo()
|
fun tooo()
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ object StandardClassIds {
|
|||||||
val PublishedApi = "PublishedApi".baseId()
|
val PublishedApi = "PublishedApi".baseId()
|
||||||
val SinceKotlin = "SinceKotlin".baseId()
|
val SinceKotlin = "SinceKotlin".baseId()
|
||||||
val ExtensionFunctionType = "ExtensionFunctionType".baseId()
|
val ExtensionFunctionType = "ExtensionFunctionType".baseId()
|
||||||
|
val ContextFunctionTypeParams = "ContextFunctionTypeParams".baseId()
|
||||||
val Deprecated = "Deprecated".baseId()
|
val Deprecated = "Deprecated".baseId()
|
||||||
val DeprecatedSinceKotlin = "DeprecatedSinceKotlin".baseId()
|
val DeprecatedSinceKotlin = "DeprecatedSinceKotlin".baseId()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user