Used named arguments for clarity
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Expression> { 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)
|
||||
}
|
||||
|
||||
|
||||
@@ -65,4 +65,4 @@ class Annotations(val annotations: List<Annotation>) : 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)
|
||||
|
||||
Reference in New Issue
Block a user