5
5
6
6
package org.jetbrains.kotlin.kotlinp
7
7
8
- import kotlin.metadata.*
9
8
import kotlin.contracts.ExperimentalContracts
9
+ import kotlin.metadata.*
10
10
11
11
abstract class Kotlinp (protected val settings : Settings ) {
12
12
fun renderAnnotation (annotation : KmAnnotation , printer : Printer ): Unit = with (printer) {
@@ -64,13 +64,11 @@ abstract class Kotlinp(protected val settings: Settings) {
64
64
}
65
65
}
66
66
67
- protected fun Printer.appendAnnotations (hasAnnotations : Boolean? , annotations : List <KmAnnotation >, onePerLine : Boolean = true) {
68
- if (hasAnnotations != false ) {
69
- annotations.forEach { annotation ->
70
- append(" @" )
71
- renderAnnotation(annotation, this )
72
- if (onePerLine) appendLine() else append(" " )
73
- }
67
+ protected fun Printer.appendAnnotations (annotations : List <KmAnnotation >, onePerLine : Boolean = true) {
68
+ annotations.forEach { annotation ->
69
+ append(" @" )
70
+ renderAnnotation(annotation, this )
71
+ if (onePerLine) appendLine() else append(" " )
74
72
}
75
73
}
76
74
@@ -79,7 +77,7 @@ abstract class Kotlinp(protected val settings: Settings) {
79
77
appendOrigin(clazz)
80
78
appendVersionRequirements(clazz.versionRequirements)
81
79
appendSignatures(clazz)
82
- appendAnnotations(clazz.hasAnnotations, getAnnotations(clazz))
80
+ appendAnnotations(getAnnotations(clazz))
83
81
appendContextReceiverTypes(clazz.contextReceiverTypes)
84
82
append(VISIBILITY_MAP [clazz.visibility])
85
83
append(MODALITY_MAP [clazz.modality])
@@ -139,7 +137,7 @@ abstract class Kotlinp(protected val settings: Settings) {
139
137
appendLine()
140
138
appendVersionRequirements(constructor .versionRequirements)
141
139
appendSignatures(constructor )
142
- appendAnnotations(constructor .hasAnnotations, getAnnotations(constructor ))
140
+ appendAnnotations(getAnnotations(constructor ))
143
141
renderConstructorModifiers(constructor , printer)
144
142
append(" constructor" )
145
143
appendValueParameters(constructor .valueParameters)
@@ -160,7 +158,7 @@ abstract class Kotlinp(protected val settings: Settings) {
160
158
appendOrigin(function)
161
159
appendVersionRequirements(function.versionRequirements)
162
160
appendSignatures(function)
163
- appendAnnotations(function.hasAnnotations, getAnnotations(function))
161
+ appendAnnotations(getAnnotations(function))
164
162
appendContextReceiverTypes(function.contextReceiverTypes)
165
163
renderFunctionModifiers(function, printer)
166
164
append(" fun " )
@@ -294,7 +292,7 @@ abstract class Kotlinp(protected val settings: Settings) {
294
292
appendVersionRequirements(property.versionRequirements)
295
293
appendSignatures(property)
296
294
appendCustomAttributes(property)
297
- appendAnnotations(property.hasAnnotations, getAnnotations(property))
295
+ appendAnnotations(getAnnotations(property))
298
296
appendContextReceiverTypes(property.contextReceiverTypes)
299
297
renderPropertyModifiers(property, printer)
300
298
append(if (property.isVar) " var " else " val " )
@@ -308,12 +306,12 @@ abstract class Kotlinp(protected val settings: Settings) {
308
306
appendLine()
309
307
withIndent {
310
308
appendGetterSignatures(property)
311
- appendAnnotations(property.getter.hasAnnotations, getGetterAnnotations(property))
309
+ appendAnnotations(getGetterAnnotations(property))
312
310
renderPropertyAccessorModifiers(property.getter, printer)
313
311
appendLine(" get" )
314
312
property.setter?.let { setter ->
315
313
appendSetterSignatures(property)
316
- appendAnnotations(setter.hasAnnotations, getSetterAnnotations(property))
314
+ appendAnnotations(getSetterAnnotations(property))
317
315
renderPropertyAccessorModifiers(setter, printer)
318
316
append(" set" )
319
317
property.setterParameter?.let {
@@ -351,7 +349,7 @@ abstract class Kotlinp(protected val settings: Settings) {
351
349
appendLine()
352
350
appendVersionRequirements(typeAlias.versionRequirements)
353
351
appendSignatures(typeAlias)
354
- appendAnnotations(typeAlias.hasAnnotations, typeAlias. annotations)
352
+ appendAnnotations(typeAlias.annotations)
355
353
append(VISIBILITY_MAP [typeAlias.visibility], " typealias " , typeAlias.name)
356
354
appendTypeParameters(typeAlias.typeParameters)
357
355
append(" = " ).appendType(typeAlias.underlyingType)
@@ -361,7 +359,7 @@ abstract class Kotlinp(protected val settings: Settings) {
361
359
362
360
fun renderTypeParameter (typeParameter : KmTypeParameter , printer : Printer ): Unit = with (printer) {
363
361
appendFlags(typeParameter.isReified to " reified" )
364
- appendAnnotations(hasAnnotations = null , getAnnotations(typeParameter), onePerLine = false )
362
+ appendAnnotations(getAnnotations(typeParameter), onePerLine = false )
365
363
if (typeParameter.variance != KmVariance .INVARIANT ) {
366
364
append(typeParameter.variance.name.lowercase()).append(" " )
367
365
}
@@ -388,7 +386,7 @@ abstract class Kotlinp(protected val settings: Settings) {
388
386
val platformTypeUpperBound = type.flexibleTypeUpperBound?.let { renderFlexibleTypeUpperBound(it) }
389
387
390
388
printer + = printString {
391
- appendAnnotations(hasAnnotations = null , getAnnotations(type), onePerLine = false )
389
+ appendAnnotations(getAnnotations(type), onePerLine = false )
392
390
appendFlags(
393
391
isRaw(type) to " /* raw */" ,
394
392
type.isSuspend to " suspend"
@@ -442,7 +440,7 @@ abstract class Kotlinp(protected val settings: Settings) {
442
440
}
443
441
444
442
fun renderValueParameter (valueParameter : KmValueParameter , printer : Printer ): Unit = with (printer) {
445
- appendAnnotations(valueParameter.hasAnnotations, getAnnotations(valueParameter), onePerLine = false )
443
+ appendAnnotations(getAnnotations(valueParameter), onePerLine = false )
446
444
appendFlags(
447
445
valueParameter.isCrossinline to " crossinline" ,
448
446
valueParameter.isNoinline to " noinline"
0 commit comments