int (@Nullable CommonCodeStyleSettings.IndentOptions options, @NotNull String oldV, @NotNull String newV) { oldV = oldV.trim(); newV = newV.trim(); int diff = 0; int oPos = 0, nPos = 0; int oEnd = oldV.length(), nEnd = newV.length(); StringBuilder oSp = new StringBuilder(); StringBuilder nSp = new StringBuilder(); char ch; while (oPos < oEnd || nPos < nEnd) { oSp.setLength(0); nSp.setLength(0); while (oPos < oEnd && isSpace(ch = oldV.charAt(oPos))) { oSp.append(ch); ++oPos; } while (nPos < nEnd && isSpace(ch = newV.charAt(nPos))) { nSp.append(ch); ++nPos; } diff += Math.abs(getNormalizedLength(options, oSp.toString()) - getNormalizedLength(options, nSp.toString())); //each time while (oPos < oEnd && nPos < nEnd && (ch = oldV.charAt(oPos)) == newV.charAt(nPos) && !isSpace(ch)) { ++oPos; ++nPos; } if (oPos < oEnd && nPos < nEnd && !isSpace(oldV.charAt(oPos)) && !isSpace(newV.charAt(nPos))) { logError("AST changed!"); return Differ.UGLY_FORMATTING; } } return diff; }