From 8e3c79376092950b99edf38bb2c92fd2c0761657 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 16 Jun 2015 16:42:33 +0300 Subject: [PATCH] Used named arguments for clarity --- j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt | 6 +++--- j2k/src/org/jetbrains/kotlin/j2k/Converter.kt | 6 +++--- j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt index 1c350af296e..cbfb430dce1 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt @@ -48,7 +48,7 @@ class AnnotationConverter(private val converter: Converter) { if (child is PsiWhiteSpace) !child.isInSingleLine() else false } - annotations.map { convertAnnotation(it, owner is PsiLocalVariable, newLines) }.filterNotNull() //TODO: brackets are also needed for local classes + annotations.map { convertAnnotation(it, withAt = owner is PsiLocalVariable, newLineAfter = newLines) }.filterNotNull() //TODO: '@' is also needed for local classes } else { listOf() @@ -70,14 +70,14 @@ class AnnotationConverter(private val converter: Converter) { LiteralExpression("\"" + StringUtil.escapeStringCharacters(deprecatedTag.content()) + "\"").assignNoPrototype() } return Annotation(Identifier("deprecated").assignPrototype(deprecatedTag.getNameElement()), - listOf(null to deferredExpression), false, true) + listOf(null to deferredExpression), withAt = false, newLineAfter = true) .assignPrototype(deprecatedTag) } private fun convertModifiersToAnnotations(owner: PsiModifierListOwner): Annotations { val list = MODIFIER_TO_ANNOTATION .filter { owner.hasModifierProperty(it.first) } - .map { Annotation(Identifier(it.second).assignNoPrototype(), listOf(), false, false).assignNoPrototype() } + .map { Annotation(Identifier(it.second).assignNoPrototype(), listOf(), withAt = false, newLineAfter = false).assignNoPrototype() } return Annotations(list).assignNoPrototype() } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt index ebee5e0a566..d67ac3661c0 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt @@ -113,7 +113,7 @@ class Converter private constructor( is PsiExpression -> createDefaultCodeConverter().convertExpression(element) is PsiImportList -> convertImportList(element) is PsiImportStatementBase -> convertImport(element, false) - is PsiAnnotation -> annotationConverter.convertAnnotation(element, false, false) + is PsiAnnotation -> annotationConverter.convertAnnotation(element, withAt = false, newLineAfter = false) is PsiPackageStatement -> PackageStatement(quoteKeywords(element.getPackageName() ?: "")).assignPrototype(element) else -> null } @@ -288,7 +288,7 @@ class Converter private constructor( classBody = ClassBody(constructorSignature, classBody.baseClassParams, classBody.members, classBody.companionObjectMembers, classBody.lBrace, classBody.rBrace, classBody.isEnumBody) - val annotationAnnotation = Annotation(Identifier("annotation").assignNoPrototype(), listOf(), false, false).assignNoPrototype() + val annotationAnnotation = Annotation(Identifier("annotation").assignNoPrototype(), listOf(), withAt = false, newLineAfter = false).assignNoPrototype() return Class(psiClass.declarationIdentifier(), convertAnnotations(psiClass) + Annotations(listOf(annotationAnnotation)), convertModifiers(psiClass).without(Modifier.ABSTRACT), @@ -581,7 +581,7 @@ class Converter private constructor( val convertedType = typeConverter.convertType(types[index], Nullability.NotNull) null to deferredElement { ClassLiteralExpression(convertedType.assignPrototype(refElements[index])) } } - val annotation = Annotation(Identifier("throws").assignNoPrototype(), arguments, false, true) + val annotation = Annotation(Identifier("throws").assignNoPrototype(), arguments, withAt = false, newLineAfter = true) return Annotations(listOf(annotation.assignPrototype(throwsList))).assignPrototype(throwsList) } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt index b0854e517de..8096dd9e840 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt @@ -65,4 +65,4 @@ class Annotations(val annotations: List) : Element() { } fun Annotations.withAt(): Annotations - = Annotations(annotations.map { Annotation(it.name, it.arguments, true, it.newLineAfter).assignPrototypesFrom(it) }).assignPrototypesFrom(this) + = Annotations(annotations.map { Annotation(it.name, it.arguments, withAt = true, newLineAfter = it.newLineAfter).assignPrototypesFrom(it) }).assignPrototypesFrom(this)