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
|
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 {
|
else {
|
||||||
listOf()
|
listOf()
|
||||||
@@ -70,14 +70,14 @@ class AnnotationConverter(private val converter: Converter) {
|
|||||||
LiteralExpression("\"" + StringUtil.escapeStringCharacters(deprecatedTag.content()) + "\"").assignNoPrototype()
|
LiteralExpression("\"" + StringUtil.escapeStringCharacters(deprecatedTag.content()) + "\"").assignNoPrototype()
|
||||||
}
|
}
|
||||||
return Annotation(Identifier("deprecated").assignPrototype(deprecatedTag.getNameElement()),
|
return Annotation(Identifier("deprecated").assignPrototype(deprecatedTag.getNameElement()),
|
||||||
listOf(null to deferredExpression), false, true)
|
listOf(null to deferredExpression), withAt = false, newLineAfter = true)
|
||||||
.assignPrototype(deprecatedTag)
|
.assignPrototype(deprecatedTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun convertModifiersToAnnotations(owner: PsiModifierListOwner): Annotations {
|
private fun convertModifiersToAnnotations(owner: PsiModifierListOwner): Annotations {
|
||||||
val list = MODIFIER_TO_ANNOTATION
|
val list = MODIFIER_TO_ANNOTATION
|
||||||
.filter { owner.hasModifierProperty(it.first) }
|
.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()
|
return Annotations(list).assignNoPrototype()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class Converter private constructor(
|
|||||||
is PsiExpression -> createDefaultCodeConverter().convertExpression(element)
|
is PsiExpression -> createDefaultCodeConverter().convertExpression(element)
|
||||||
is PsiImportList -> convertImportList(element)
|
is PsiImportList -> convertImportList(element)
|
||||||
is PsiImportStatementBase -> convertImport(element, false)
|
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)
|
is PsiPackageStatement -> PackageStatement(quoteKeywords(element.getPackageName() ?: "")).assignPrototype(element)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ class Converter private constructor(
|
|||||||
classBody = ClassBody(constructorSignature, classBody.baseClassParams, classBody.members,
|
classBody = ClassBody(constructorSignature, classBody.baseClassParams, classBody.members,
|
||||||
classBody.companionObjectMembers, classBody.lBrace, classBody.rBrace, classBody.isEnumBody)
|
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(),
|
return Class(psiClass.declarationIdentifier(),
|
||||||
convertAnnotations(psiClass) + Annotations(listOf(annotationAnnotation)),
|
convertAnnotations(psiClass) + Annotations(listOf(annotationAnnotation)),
|
||||||
convertModifiers(psiClass).without(Modifier.ABSTRACT),
|
convertModifiers(psiClass).without(Modifier.ABSTRACT),
|
||||||
@@ -581,7 +581,7 @@ class Converter private constructor(
|
|||||||
val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
|
val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
|
||||||
null to deferredElement<Expression> { ClassLiteralExpression(convertedType.assignPrototype(refElements[index])) }
|
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)
|
return Annotations(listOf(annotation.assignPrototype(throwsList))).assignPrototype(throwsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,4 +65,4 @@ class Annotations(val annotations: List<Annotation>) : Element() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Annotations.withAt(): Annotations
|
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