Skip to content

Commit 02122a6

Browse files
committed
increase level to 12
relative symlink? comment sptless comments
1 parent e359beb commit 02122a6

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

palantir-java-format-benchmarks/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ tasks.named('jmh', JMHTask.class) {
3333

3434
spotless {
3535
java {
36+
// symlinks to a test input file that shouldn't be formatted
3637
targetExclude 'src/test/resources/*'
3738
}
3839
}

palantir-java-format-benchmarks/src/jmh/java/com/palantir/javaformat/BenchmarkMultiFiles.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ public final void runJar(BenchmarkState state) throws InterruptedException, IOEx
130130

131131
public static void main(String[] _args) throws RunnerException {
132132
new Runner(new OptionsBuilder()
133-
.include(BenchmarkMultiFiles.class.getSimpleName())
134-
.build())
133+
.include(BenchmarkMultiFiles.class.getSimpleName())
134+
.build())
135135
.run();
136136
}
137137
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/Volumes/git/palantir-java-format/palantir-java-format/src/test/resources/com/palantir/javaformat/java/testdata/palantir-deeply-nested-calls.input
1+
../../../../palantir-java-format/src/test/resources/com/palantir/javaformat/java/testdata/palantir-deeply-nested-calls.input

palantir-java-format/src/main/java/com/palantir/javaformat/doc/Level.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final class Level extends Doc {
5454
/**
5555
* The depth of nested levels in the current level tree from which we explore both breaking vs not breaking the current level.
5656
*/
57-
private static final int LAST_LEVELS_TO_EXPLORE = 7;
57+
private static final int LAST_LEVELS_TO_EXPLORE = 12;
5858

5959
private static final Collector<Level, ?, Optional<Level>> GET_LAST_COLLECTOR = Collectors.reducing((u, v) -> v);
6060

@@ -758,9 +758,7 @@ private int getMaxDepth() {
758758
}
759759

760760
/**
761-
* Calculate an approximation of the maximum depth of nested levels in this level tree, counting method call nesting.
762-
* This counts levels that represent method invocations (including lambdas and other callable constructs),
763-
* which provides a better measure of structural complexity than counting all levels.
761+
* Calculates the maximum depth of nested levels in this level tree.
764762
* This computation is expensive, so it's memoized via {@link #getMaxDepth()}.
765763
*/
766764
private int computeMaxDepth(Iterable<Doc> docs) {
@@ -772,10 +770,7 @@ private int computeMaxDepth(Iterable<Doc> docs) {
772770
}
773771
}
774772

775-
// Count this level if it represents a method call or similar construct
776-
// A level is considered a "method call level" if it has breaks (can span multiple lines)
777-
// and is not just a simple wrapper. We use the presence of breaks as a proxy for
778-
// meaningful structural nesting.
773+
// We use the presence of breaks as a proxy for meaningful structural nesting.
779774
boolean hasBreaks = false;
780775
for (Doc doc : docs) {
781776
if (doc instanceof Break) {
@@ -784,7 +779,7 @@ private int computeMaxDepth(Iterable<Doc> docs) {
784779
}
785780
}
786781

787-
// Only count levels that have breaks (i.e., can actually be formatted across multiple lines)
782+
// Only count levels that have breaks (which can actually be formatted across multiple lines)
788783
return hasBreaks ? 1 + maxChildDepth : maxChildDepth;
789784
}
790785

0 commit comments

Comments
 (0)