Commit 19cf7c9f authored by Skylot's avatar Skylot

refactor: improve multi line warning print

parent 363cd85b
...@@ -84,7 +84,7 @@ public final class ResourcesLoader { ...@@ -84,7 +84,7 @@ public final class ResourcesLoader {
LOG.error("Decode error", e); LOG.error("Decode error", e);
CodeWriter cw = new CodeWriter(); CodeWriter cw = new CodeWriter();
cw.add("Error decode ").add(rf.getType().toString().toLowerCase()); 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); return ResContainer.textResource(rf.getName(), cw);
} }
} }
......
...@@ -263,7 +263,7 @@ public class ClassGen { ...@@ -263,7 +263,7 @@ public class ClassGen {
} catch (Exception e) { } catch (Exception e) {
code.newLine().add("/*"); code.newLine().add("/*");
code.newLine().addMultiLine(ErrorsCounter.methodError(mth, "Method generation error", e)); code.newLine().addMultiLine(ErrorsCounter.methodError(mth, "Method generation error", e));
code.newLine().addMultiLine(Utils.getStackTrace(e)); Utils.appendStackTrace(code, e);
code.newLine().add("*/"); code.newLine().add("*/");
code.setIndent(savedIndent); code.setIndent(savedIndent);
mth.addError("Method generation error: " + e.getMessage(), e); mth.addError("Method generation error: " + e.getMessage(), e);
......
...@@ -97,10 +97,12 @@ public class CodeWriter { ...@@ -97,10 +97,12 @@ public class CodeWriter {
} }
public CodeWriter addMultiLine(String str) { public CodeWriter addMultiLine(String str) {
buf.append(str);
if (str.contains(NL)) { if (str.contains(NL)) {
buf.append(str.replace(NL, NL + indentStr));
line += StringUtils.countMatches(str, NL); line += StringUtils.countMatches(str, NL);
offset = 0; offset = 0;
} else {
buf.append(str);
} }
return this; return this;
} }
......
...@@ -84,8 +84,8 @@ public class CheckRegions extends AbstractVisitor { ...@@ -84,8 +84,8 @@ public class CheckRegions extends AbstractVisitor {
private static String getBlockInsnStr(MethodNode mth, IBlock block) { private static String getBlockInsnStr(MethodNode mth, IBlock block) {
CodeWriter code = new CodeWriter(); CodeWriter code = new CodeWriter();
code.incIndent();
code.newLine(); code.newLine();
code.setIndent(3);
MethodGen mg = MethodGen.getFallbackMethodGen(mth); MethodGen mg = MethodGen.getFallbackMethodGen(mth);
InsnGen ig = new InsnGen(mg, true); InsnGen ig = new InsnGen(mg, true);
for (InsnNode insn : block.getInstructions()) { for (InsnNode insn : block.getInstructions()) {
...@@ -95,7 +95,7 @@ public class CheckRegions extends AbstractVisitor { ...@@ -95,7 +95,7 @@ public class CheckRegions extends AbstractVisitor {
// ignore // ignore
} }
} }
code.newLine().addIndent(); code.newLine();
code.finish(); code.finish();
return code.toString(); return code.toString();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment