Skip to content

Commit

Permalink
#1885 - fixed checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Graur committed May 5, 2023
1 parent 6851a2d commit 27ed9b1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions eo-parser/src/main/java/org/eolang/parser/XeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -540,20 +540,20 @@ private static String sourceText(final ProgramParser.ProgramContext ctx) {
*/
private static String trimMargin(final String text, final int indent) {
final String rexp = "[\\s]{%d}";
String cutted = text
final String cutted = text
.substring(3, text.length() - 3).trim();
String[] splitted = cutted.split("\n");
String res = "";
for(String line : splitted) {
res += line.replaceAll(String.format(rexp, indent), "") + "\n";
final String[] splitted = cutted.split("\n");
StringBuilder res = new StringBuilder();
for (final String line : splitted) {
res.append(line.replaceAll(String.format(rexp, indent), "")).append('\n');
}
if (!res.isEmpty() && res.charAt(0) == '\n') {
res = res.substring(1);
if (res.length() > 0 && res.charAt(0) == '\n') {
res = new StringBuilder(res.substring(1));
}
if (!res.isEmpty() && res.charAt(res.length() - 1) == '\n') {
res = res.substring(0, res.length() - 1);
if (res.length() > 0 && res.charAt(res.length() - 1) == '\n') {
res = new StringBuilder(res.substring(0, res.length() - 1));
}
return res;
return res.toString();
}

/**
Expand Down

0 comments on commit 27ed9b1

Please sign in to comment.