Render targeted annotations without escaping brackets

This commit is contained in:
Yan Zhulanow
2015-08-27 19:47:37 +03:00
parent 298093c4bd
commit 9dbd355e92
@@ -339,18 +339,22 @@ internal class DescriptorRendererImpl(
if (DescriptorRendererModifier.ANNOTATIONS !in modifiers) return
val excluded = if (annotated is JetType) excludedTypeAnnotationClasses else excludedAnnotationClasses
var hasTargetedAnnotations = false
val annotationsBuilder = StringBuilder {
for ((annotation, target) in annotated.getAnnotations().getAllAnnotations()) {
val annotationClass = annotation.getType().getConstructor().getDeclarationDescriptor() as ClassDescriptor
if (!excluded.contains(DescriptorUtils.getFqNameSafe(annotationClass))) {
if (target != null && !hasTargetedAnnotations) {
hasTargetedAnnotations = true
}
append(renderAnnotation(annotation, target)).append(" ")
}
}
}
if (!needBrackets) {
if (!needBrackets || hasTargetedAnnotations) {
builder.append(annotationsBuilder)
}
else if (annotationsBuilder.length() > 0) {