calculate less indent buffers
This commit is contained in:
@@ -149,8 +149,7 @@ public class ClassWriter {
|
||||
|
||||
methodLambdaToJava(node, classNode, mt, buffer, indent + 1, !lambdaToAnonymous, tracer);
|
||||
|
||||
InterpreterUtil.appendIndent(buffer, indent);
|
||||
buffer.append("}");
|
||||
buffer.appendIndent(indent).append("}");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -265,8 +264,7 @@ public class ClassWriter {
|
||||
}
|
||||
}
|
||||
|
||||
InterpreterUtil.appendIndent(buffer, indent);
|
||||
buffer.append('}');
|
||||
buffer.appendIndent(indent).append('}');
|
||||
|
||||
if (node.type != ClassNode.CLASS_ANONYMOUS) {
|
||||
buffer.append(lineSeparator);
|
||||
@@ -281,7 +279,6 @@ public class ClassWriter {
|
||||
|
||||
private void writeClassDefinition(ClassNode node, TextBuffer buffer, int indent) {
|
||||
String lineSeparator = DecompilerContext.getNewLineSeparator();
|
||||
String indentString = InterpreterUtil.getIndentString(indent);
|
||||
|
||||
if (node.type == ClassNode.CLASS_ANONYMOUS) {
|
||||
buffer.append(" {");
|
||||
@@ -300,7 +297,7 @@ public class ClassWriter {
|
||||
boolean isAnnotation = (flags & CodeConstants.ACC_ANNOTATION) != 0;
|
||||
|
||||
if (isDeprecated) {
|
||||
appendDeprecation(buffer, indentString, lineSeparator);
|
||||
appendDeprecation(buffer, indent, lineSeparator);
|
||||
}
|
||||
|
||||
if (interceptor != null) {
|
||||
@@ -309,12 +306,12 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
if (isSynthetic) {
|
||||
appendComment(buffer, "synthetic class", indentString, lineSeparator);
|
||||
appendComment(buffer, "synthetic class", indent, lineSeparator);
|
||||
}
|
||||
|
||||
appendAnnotations(buffer, cl, indent, lineSeparator);
|
||||
|
||||
buffer.append(indentString);
|
||||
buffer.appendIndent(indent);
|
||||
|
||||
if (isEnum) {
|
||||
// remove abstract and final flags (JLS 8.9 Enums)
|
||||
@@ -391,7 +388,6 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
private void fieldToJava(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent, BytecodeMappingTracer tracer) {
|
||||
String indentString = InterpreterUtil.getIndentString(indent);
|
||||
String lineSeparator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE);
|
||||
@@ -399,7 +395,7 @@ public class ClassWriter {
|
||||
boolean isEnum = fd.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM);
|
||||
|
||||
if (isDeprecated) {
|
||||
appendDeprecation(buffer, indentString, lineSeparator);
|
||||
appendDeprecation(buffer, indent, lineSeparator);
|
||||
}
|
||||
|
||||
if (interceptor != null) {
|
||||
@@ -408,12 +404,12 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
if (fd.isSynthetic()) {
|
||||
appendComment(buffer, "synthetic field", indentString, lineSeparator);
|
||||
appendComment(buffer, "synthetic field", indent, lineSeparator);
|
||||
}
|
||||
|
||||
appendAnnotations(buffer, fd, indent, lineSeparator);
|
||||
|
||||
buffer.append(indentString);
|
||||
buffer.appendIndent(indent);
|
||||
|
||||
if (!isEnum) {
|
||||
appendModifiers(buffer, fd.getAccessFlags(), FIELD_ALLOWED, isInterface, FIELD_EXCLUDED);
|
||||
@@ -494,7 +490,7 @@ public class ClassWriter {
|
||||
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.method_descriptor);
|
||||
|
||||
if (!codeOnly) {
|
||||
InterpreterUtil.appendIndent(buffer, indent);
|
||||
buffer.appendIndent(indent);
|
||||
buffer.append("public ");
|
||||
buffer.append(method_name);
|
||||
buffer.append("(");
|
||||
@@ -547,7 +543,7 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
if (methodWrapper.decompiledWithErrors) {
|
||||
InterpreterUtil.appendIndent(buffer, indent);
|
||||
buffer.appendIndent(indent);
|
||||
buffer.append("// $FF: Couldn't be decompiled");
|
||||
buffer.append(DecompilerContext.getNewLineSeparator());
|
||||
}
|
||||
@@ -555,7 +551,7 @@ public class ClassWriter {
|
||||
if (!codeOnly) {
|
||||
indent -= 1;
|
||||
|
||||
InterpreterUtil.appendIndent(buffer, indent);
|
||||
buffer.appendIndent(indent);
|
||||
buffer.append('}');
|
||||
buffer.append(DecompilerContext.getNewLineSeparator());
|
||||
}
|
||||
@@ -573,7 +569,6 @@ public class ClassWriter {
|
||||
boolean hideMethod = false;
|
||||
int start_index_method = buffer.length();
|
||||
|
||||
String indentString = InterpreterUtil.getIndentString(indent);
|
||||
String lineSeparator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
MethodWrapper outerWrapper = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER);
|
||||
@@ -606,7 +601,7 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
if (isDeprecated) {
|
||||
appendDeprecation(buffer, indentString, lineSeparator);
|
||||
appendDeprecation(buffer, indent, lineSeparator);
|
||||
}
|
||||
|
||||
if (interceptor != null) {
|
||||
@@ -617,15 +612,15 @@ public class ClassWriter {
|
||||
boolean isSynthetic = (flags & CodeConstants.ACC_SYNTHETIC) != 0 || mt.getAttributes().containsKey("Synthetic");
|
||||
boolean isBridge = (flags & CodeConstants.ACC_BRIDGE) != 0;
|
||||
if (isSynthetic) {
|
||||
appendComment(buffer, "synthetic method", indentString, lineSeparator);
|
||||
appendComment(buffer, "synthetic method", indent, lineSeparator);
|
||||
}
|
||||
if (isBridge) {
|
||||
appendComment(buffer, "bridge method", indentString, lineSeparator);
|
||||
appendComment(buffer, "bridge method", indent, lineSeparator);
|
||||
}
|
||||
|
||||
appendAnnotations(buffer, mt, indent, lineSeparator);
|
||||
|
||||
buffer.append(indentString);
|
||||
buffer.appendIndent(indent);
|
||||
|
||||
appendModifiers(buffer, flags, METHOD_ALLOWED, isInterface, METHOD_EXCLUDED);
|
||||
|
||||
@@ -811,8 +806,7 @@ public class ClassWriter {
|
||||
|
||||
//TODO: for now only start line set
|
||||
buffer.setCurrentLine(startLine);
|
||||
buffer.append('{');
|
||||
buffer.append(lineSeparator);
|
||||
buffer.append('{').appendLineSeparator();
|
||||
|
||||
RootStatement root = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor()).root;
|
||||
|
||||
@@ -834,14 +828,12 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
if (methodWrapper.decompiledWithErrors) {
|
||||
buffer.append(InterpreterUtil.getIndentString(indent + 1));
|
||||
buffer.appendIndent(indent + 1);
|
||||
buffer.append("// $FF: Couldn't be decompiled");
|
||||
buffer.append(lineSeparator);
|
||||
}
|
||||
|
||||
buffer.append(indentString);
|
||||
buffer.append('}');
|
||||
buffer.append(lineSeparator);
|
||||
buffer.appendIndent(indent).append('}').appendLineSeparator();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -872,8 +864,8 @@ public class ClassWriter {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void appendDeprecation(TextBuffer buffer, String indentString, String lineSeparator) {
|
||||
buffer.append(indentString).append("/** @deprecated */").append(lineSeparator);
|
||||
private static void appendDeprecation(TextBuffer buffer, int indent, String lineSeparator) {
|
||||
buffer.appendIndent(indent).append("/** @deprecated */").append(lineSeparator);
|
||||
}
|
||||
|
||||
private enum MType {CLASS, FIELD, METHOD}
|
||||
@@ -881,7 +873,7 @@ public class ClassWriter {
|
||||
private static void appendRenameComment(TextBuffer buffer, String oldName, MType type, int indent, String lineSeparator) {
|
||||
if (oldName == null) return;
|
||||
|
||||
InterpreterUtil.appendIndent(buffer, indent);
|
||||
buffer.appendIndent(indent);
|
||||
buffer.append("// $FF: renamed from: ");
|
||||
|
||||
switch (type) {
|
||||
@@ -926,8 +918,8 @@ public class ClassWriter {
|
||||
return typeText;
|
||||
}
|
||||
|
||||
private static void appendComment(TextBuffer buffer, String comment, String indentString, String lineSeparator) {
|
||||
buffer.append(indentString).append("// $FF: ").append(comment).append(lineSeparator);
|
||||
private static void appendComment(TextBuffer buffer, String comment, int indent, String lineSeparator) {
|
||||
buffer.appendIndent(indent).append("// $FF: ").append(comment).append(lineSeparator);
|
||||
}
|
||||
|
||||
private static final String[] ANNOTATION_ATTRIBUTES = {
|
||||
|
||||
Reference in New Issue
Block a user