String (@NotNull String codeFragment, int addIndent) { Scanner s = new Scanner(codeFragment); List<String> lines = new ArrayList<>(); List<Integer> indents = new ArrayList<>(); while (s.hasNextLine()) { String line = s.nextLine(); int indent = 0; for (char c : line.toCharArray()) { if (c == ' ') { indent++; } else if (c == '\t') { indent += TAB_INDENT; } else { break; } } if (!StringUtil.isEmpty(line)) { lines.add(line.trim()); indents.add(indent); } } int[] indentArray = ArrayUtil.toIntArray(indents); shiftLeftAll(indentArray, lines); for (int i = 0; i < indentArray.length; i++) { indentArray[i] += addIndent; } return padOutput(lines, indentArray); }