[java-decompiler] fixes indentation in annotations

This commit is contained in:
Roman Shevchenko
2016-04-20 17:57:57 +02:00
parent eaa61a1f81
commit 4a1a747bdc
8 changed files with 206 additions and 11 deletions

View File

@@ -816,7 +816,7 @@ public class ClassWriter {
StructAnnDefaultAttribute attr = (StructAnnDefaultAttribute)mt.getAttributes().getWithKey("AnnotationDefault");
if (attr != null) {
buffer.append(" default ");
buffer.append(attr.getDefaultValue().toJava(indent + 1, new BytecodeMappingTracer())); // dummy tracer
buffer.append(attr.getDefaultValue().toJava(0, new BytecodeMappingTracer())); // dummy tracer
}
}
@@ -970,7 +970,6 @@ public class ClassWriter {
StructGeneralAttribute.ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS};
private static void appendParameterAnnotations(TextBuffer buffer, StructMethod mt, int param) {
BytecodeMappingTracer tracer_dummy = new BytecodeMappingTracer(); // FIXME: replace with a real one
for (String name : PARAMETER_ANNOTATION_ATTRIBUTES) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import org.jetbrains.java.decompiler.util.InterpreterUtil;
import java.util.List;
public class AnnotationExprent extends Exprent {
public static final int ANNOTATION_NORMAL = 1;
public static final int ANNOTATION_MARKER = 2;
public static final int ANNOTATION_SINGLE_ELEMENT = 3;
@@ -45,12 +44,12 @@ public class AnnotationExprent extends Exprent {
TextBuffer buffer = new TextBuffer();
buffer.appendIndent(indent);
buffer.append("@");
buffer.append('@');
buffer.append(DecompilerContext.getImportCollector().getShortName(ExprProcessor.buildJavaClassName(className)));
if (!parNames.isEmpty()) {
buffer.append("(");
if (parNames.size() == 1 && "value".equals(parNames.get(0))) {
buffer.append('(');
if (getAnnotationType() == ANNOTATION_SINGLE_ELEMENT) {
buffer.append(parValues.get(0).toJava(indent + 1, tracer));
}
else {
@@ -58,16 +57,16 @@ public class AnnotationExprent extends Exprent {
buffer.appendLineSeparator().appendIndent(indent + 1);
buffer.append(parNames.get(i));
buffer.append(" = ");
buffer.append(parValues.get(i).toJava(indent + 2, tracer));
buffer.append(parValues.get(i).toJava(0, tracer));
if (i < parNames.size() - 1) {
buffer.append(",");
buffer.append(',');
}
}
buffer.appendLineSeparator().appendIndent(indent);
}
buffer.append(")");
buffer.append(')');
}
return buffer;
@@ -99,4 +98,4 @@ public class AnnotationExprent extends Exprent {
InterpreterUtil.equalLists(parNames, ann.parNames) &&
InterpreterUtil.equalLists(parValues, ann.parValues);
}
}
}