|
@@ -190,9 +190,7 @@ public final class TokenPrinter {
|
|
|
* @return the shortened file name
|
|
* @return the shortened file name
|
|
|
*/
|
|
*/
|
|
|
private static String restoreTokenFileName(String fileName, Optional<String> suffix) {
|
|
private static String restoreTokenFileName(String fileName, Optional<String> suffix) {
|
|
|
- if (suffix.isEmpty()) {
|
|
|
|
|
- return fileName;
|
|
|
|
|
- } else if (!fileName.endsWith(suffix.get())) {
|
|
|
|
|
|
|
+ if (suffix.isEmpty() || !fileName.endsWith(suffix.get())) {
|
|
|
return fileName;
|
|
return fileName;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -214,18 +212,6 @@ public final class TokenPrinter {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Returns the number of digits (including a minus) of the given number.
|
|
|
|
|
- */
|
|
|
|
|
- private static int digitCount(int number) {
|
|
|
|
|
- if (number == 0) {
|
|
|
|
|
- return 1;
|
|
|
|
|
- }
|
|
|
|
|
- int minusLength = number < 0 ? 1 : 0;
|
|
|
|
|
- // The 'log10' variant is supposedly faster than the 'toString' variant.
|
|
|
|
|
- return (int) Math.log10(Math.abs(number)) + minusLength + 1;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* This contains all data concerning a line of code in a file and the tokens found in that line.
|
|
* This contains all data concerning a line of code in a file and the tokens found in that line.
|
|
|
* @param file the file
|
|
* @param file the file
|
|
@@ -276,6 +262,18 @@ public final class TokenPrinter {
|
|
|
private int lineNumber;
|
|
private int lineNumber;
|
|
|
private int trailingLineSeparators = 0;
|
|
private int trailingLineSeparators = 0;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns the number of digits (including a minus) of the given number.
|
|
|
|
|
+ */
|
|
|
|
|
+ private static int digitCount(int number) {
|
|
|
|
|
+ if (number == 0) {
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ int minusLength = number < 0 ? 1 : 0;
|
|
|
|
|
+ // The 'log10' variant is supposedly faster than the 'toString' variant.
|
|
|
|
|
+ return (int) Math.log10(Math.abs(number)) + minusLength + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void resetLinePosition() {
|
|
private void resetLinePosition() {
|
|
|
columnIndex = 1;
|
|
columnIndex = 1;
|
|
|
}
|
|
}
|
|
@@ -360,8 +358,8 @@ public final class TokenPrinter {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// The replacement operation preserves TAB characters, which is essential for correct alignment
|
|
// The replacement operation preserves TAB characters, which is essential for correct alignment
|
|
|
- String padding = currentLine.substring(columnIndex - 1, targetPosition - 1).replaceAll(TAB, REPLACE_TABS ? TAB_REPLACEMENT : TAB)
|
|
|
|
|
- .replaceAll(NON_WHITESPACE, SPACE);
|
|
|
|
|
|
|
+ String padding = currentLine.substring(columnIndex - 1, targetPosition - 1).replace(TAB, REPLACE_TABS ? TAB_REPLACEMENT : TAB)
|
|
|
|
|
+ .replace(NON_WHITESPACE, SPACE);
|
|
|
append(padding);
|
|
append(padding);
|
|
|
|
|
|
|
|
return this;
|
|
return this;
|