Skip to content

Commit 01dbff5

Browse files
authored
Document log10 usage in TraceDiagnosticRepresentation.java
Signed-off-by: ascopes <73482956+ascopes@users.noreply.github.com>
1 parent 62b1405 commit 01dbff5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/TraceDiagnosticRepresentation.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ private Snippet(String text, long startLine, long startOffset, long endOffset) {
208208
this.endOffset = endOffset;
209209

210210
// Width of the line number part of the output.
211+
// Use log10 to determine the number of decimal digits
212+
// to use. This allows us to produce a consistent width
213+
// margin that will fit every line number. We only show a
214+
// few lines in the snippet usually, so adding 1 more
215+
// digit to this provides us safety if the snippet were
216+
// to start on line 99 and move into line 100.
211217
lineNumberWidth = (int) Math.ceil(Math.log10(startLine)) + 1;
212218
}
213219

0 commit comments

Comments
 (0)