提交 19cf7c9f 编写于 作者: S Skylot

refactor: improve multi line warning print

上级 363cd85b
......@@ -84,7 +84,7 @@ public final class ResourcesLoader {
LOG.error("Decode error", e);
CodeWriter cw = new CodeWriter();
cw.add("Error decode ").add(rf.getType().toString().toLowerCase());
cw.startLine(Utils.getStackTrace(e.getCause()));
Utils.appendStackTrace(cw, e.getCause());
return ResContainer.textResource(rf.getName(), cw);
}
}
......
......@@ -263,7 +263,7 @@ public class ClassGen {
} catch (Exception e) {
code.newLine().add("/*");
code.newLine().addMultiLine(ErrorsCounter.methodError(mth, "Method generation error", e));
code.newLine().addMultiLine(Utils.getStackTrace(e));
Utils.appendStackTrace(code, e);
code.newLine().add("*/");
code.setIndent(savedIndent);
mth.addError("Method generation error: " + e.getMessage(), e);
......
......@@ -97,10 +97,12 @@ public class CodeWriter {
}
public CodeWriter addMultiLine(String str) {
buf.append(str);
if (str.contains(NL)) {
buf.append(str.replace(NL, NL + indentStr));
line += StringUtils.countMatches(str, NL);
offset = 0;
} else {
buf.append(str);
}
return this;
}
......
......@@ -84,8 +84,8 @@ public class CheckRegions extends AbstractVisitor {
private static String getBlockInsnStr(MethodNode mth, IBlock block) {
CodeWriter code = new CodeWriter();
code.incIndent();
code.newLine();
code.setIndent(3);
MethodGen mg = MethodGen.getFallbackMethodGen(mth);
InsnGen ig = new InsnGen(mg, true);
for (InsnNode insn : block.getInstructions()) {
......@@ -95,7 +95,7 @@ public class CheckRegions extends AbstractVisitor {
// ignore
}
}
code.newLine().addIndent();
code.newLine();
code.finish();
return code.toString();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册