File tree Expand file tree Collapse file tree
main/java/com/palantir/javaformat/doc
test/resources/com/palantir/javaformat/java/testdata Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,15 +67,11 @@ public Float visitLevel(Level level) {
6767 if (found .isPresent ()) {
6868 return visit (level .getDocs ().get (found .getAsInt ()));
6969 }
70- // Otherwise, assert that we encountered a break and move on.
71- if (StartsWithBreakVisitor .INSTANCE .visit (level ) != Result .YES ) {
72- // Avoid computing expensive level.representation() if we aren't throwing it in an exception.
73- throw new IllegalStateException (String .format (
74- "Didn't find expected break at the beginning of level.\n %s" ,
75- level .representation (State .startingState ())));
76- }
77-
78- return 0f ;
70+ // Level starts with tokens directly (e.g. method reference qualifier) — sum doc widths up to the first break.
71+ return level .getDocs ().stream ()
72+ .takeWhile (doc -> !(doc instanceof Break ))
73+ .map (Doc ::getWidth )
74+ .reduce (0f , Float ::sum );
7975 }
8076
8177 /**
Original file line number Diff line number Diff line change @@ -80,5 +80,18 @@ class A {
8080 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2
8181 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2
8282 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
83+ return StreamEx.of(itemsToCreate)
84+ .append(itemsToEdit)
85+ .append(itemsToDelete)
86+ .distinct()
87+ .mapToEntry(item -> getArgsGenerator()
88+ .getNewArgs(
89+ extendedItems.getOrDefault(item, Set.of()),
90+ getOwningResource(
91+ item,
92+ getModificationContext()::getRestrictionStatusOrDefault,
93+ RestrictionStatus::getPackageId,
94+ getModificationContext())))
95+ .toImmutableMap();
8396 }
8497}
Original file line number Diff line number Diff line change @@ -70,5 +70,18 @@ class A {
7070 something = 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2
7171 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2
7272 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
73+ return StreamEx.of(itemsToCreate)
74+ .append(itemsToEdit)
75+ .append(itemsToDelete)
76+ .distinct()
77+ .mapToEntry(item -> getArgsGenerator()
78+ .getNewArgs(
79+ extendedItems.getOrDefault(item, Set.of()),
80+ getOwningResource(
81+ item,
82+ getModificationContext()::getRestrictionStatusOrDefault,
83+ RestrictionStatus::getPackageId,
84+ getModificationContext())))
85+ .toImmutableMap();
7386 }
7487}
You can’t perform that action at this time.
0 commit comments