Skip to content

Commit 182fd9a

Browse files
committed
Java 21: rebase + fix Unnamed pattern
1 parent c5a0bc7 commit 182fd9a

File tree

5 files changed

+45
-69
lines changed

5 files changed

+45
-69
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ allprojects {
3838
apply plugin: 'com.palantir.java-format'
3939
apply plugin: 'com.palantir.jakarta-package-alignment'
4040
group = 'com.palantir.javaformat'
41-
version = rootProject.version
41+
version = "2.44.1"
4242

4343
repositories {
4444
mavenLocal() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } }

palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ public Void visitCompilationUnit(CompilationUnitTree node, Void unused) {
390390
return null;
391391
}
392392

393-
protected void handleModule(boolean first, CompilationUnitTree node) {}
393+
protected void handleModule(boolean first, CompilationUnitTree node) {
394+
}
394395

395396
/** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */
396397
protected void dropEmptyDeclarations() {
@@ -1005,7 +1006,7 @@ public Void visitForLoop(ForLoopTree node, Void unused) {
10051006
builder.open(plusFour);
10061007
builder.open(
10071008
node.getInitializer().size() > 1
1008-
&& node.getInitializer().get(0).getKind() == Tree.Kind.EXPRESSION_STATEMENT
1009+
&& node.getInitializer().get(0).getKind() == Tree.Kind.EXPRESSION_STATEMENT
10091010
? plusFour
10101011
: ZERO);
10111012
if (!node.getInitializer().isEmpty()) {
@@ -1611,12 +1612,12 @@ private boolean handleLogStatement(MethodInvocationTree node) {
16111612

16121613
private static List<Long> handleStream(List<ExpressionTree> parts) {
16131614
return indexes(parts.stream(), p -> {
1614-
if (!(p instanceof MethodInvocationTree)) {
1615-
return false;
1616-
}
1617-
Name name = getMethodName((MethodInvocationTree) p);
1618-
return Stream.of("stream", "parallelStream", "toBuilder").anyMatch(name::contentEquals);
1619-
})
1615+
if (!(p instanceof MethodInvocationTree)) {
1616+
return false;
1617+
}
1618+
Name name = getMethodName((MethodInvocationTree) p);
1619+
return Stream.of("stream", "parallelStream", "toBuilder").anyMatch(name::contentEquals);
1620+
})
16201621
.collect(toList());
16211622
}
16221623

@@ -1783,7 +1784,12 @@ public Void visitPrimitiveType(PrimitiveTypeTree node, Void unused) {
17831784
}
17841785

17851786
public boolean visit(Name name) {
1786-
token(name.toString());
1787+
String value = name.toString();
1788+
if (value.isEmpty()) {
1789+
token("_");
1790+
} else {
1791+
token(value);
1792+
}
17871793
return false;
17881794
}
17891795

@@ -2471,8 +2477,8 @@ public Void visitModule(ModuleTree node, Void unused) {
24712477
markForPartialFormat();
24722478
builder.blankLineWanted(
24732479
previousDirective
2474-
.map(k -> !k.equals(directiveTree.getKind()))
2475-
.orElse(false)
2480+
.map(k -> !k.equals(directiveTree.getKind()))
2481+
.orElse(false)
24762482
? BlankLineWanted.YES
24772483
: BlankLineWanted.NO);
24782484
builder.forcedBreak();
@@ -2926,7 +2932,7 @@ private void visitDotWithPrefix(
29262932
* <li>{@code foo().bar()[0]}
29272933
* <li>{@code foo().bar()[0][0]}
29282934
* </ul>
2929-
*
2935+
* <p>
29302936
* Whereas an expression like a name {@code com.palantir.foo.bar.Baz} would not.
29312937
*/
29322938
private boolean shouldHaveColumnLimit(ExpressionTree expr) {
@@ -3413,8 +3419,8 @@ int declareOne(
34133419

34143420
builder.open(
34153421
kind == DeclarationKind.PARAMETER
3416-
&& (modifiers.isPresent()
3417-
&& !modifiers.get().getAnnotations().isEmpty())
3422+
&& (modifiers.isPresent()
3423+
&& !modifiers.get().getAnnotations().isEmpty())
34183424
? plusFour
34193425
: ZERO);
34203426
{
@@ -3519,7 +3525,7 @@ private void maybeAddDims(Deque<List<? extends AnnotationTree>> annotations) {
35193525
*
35203526
* @param dimExpressions an ordered list of dimension expressions (e.g. the {@code 0} in {@code new int[0]}
35213527
* @param annotations an ordered list of type annotations grouped by dimension (e.g. {@code [[@A, @B], [@C]]} for
3522-
* {@code int @A [] @B @C []}
3528+
* {@code int @A [] @B @C []}
35233529
*/
35243530
private void maybeAddDims(Deque<ExpressionTree> dimExpressions, Deque<List<? extends AnnotationTree>> annotations) {
35253531
boolean lastWasAnnotation = false;
@@ -3675,6 +3681,7 @@ protected void addBodyDeclarations(
36753681
}
36763682
}
36773683
}
3684+
36783685
/** Gets the permits clause for the given node. This is only available in Java 15 and later. */
36793686
protected List<? extends Tree> getPermitsClause(ClassTree node) {
36803687
return ImmutableList.of();
@@ -3762,7 +3769,7 @@ private Direction canLocalHaveHorizontalAnnotations(ModifiersTree modifiers) {
37623769
}
37633770
}
37643771
return markerAnnotations <= 1
3765-
&& markerAnnotations == modifiers.getAnnotations().size()
3772+
&& markerAnnotations == modifiers.getAnnotations().size()
37663773
? Direction.HORIZONTAL
37673774
: Direction.VERTICAL;
37683775
}

palantir-java-format21/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mainClassName = 'com.palantir.javaformat.java.Main'
5050
description = 'Palantir Java Format Java 21'
5151

5252
dependencies {
53-
implementation "com.palantir.javaformat:palantir-java-format:2.39"
53+
implementation "com.palantir.javaformat:palantir-java-format:2.44.0-3-gc5a0bc7.dirty"
5454
testImplementation 'com.google.guava:guava-testlib'
5555
testImplementation 'com.google.truth:truth'
5656
testImplementation 'com.google.testing.compile:compile-testing'
Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,40 @@
11
# Run ./gradlew --write-locks to regenerate this file
2-
com.diffplug.durian:durian-collect:1.2.0 (3 constraints: 4d313bd2)
3-
com.diffplug.durian:durian-core:1.2.0 (4 constraints: 2640ae56)
4-
com.diffplug.durian:durian-io:1.2.0 (1 constraints: 1313c62d)
5-
com.diffplug.durian:durian-swt.os:4.2.0 (1 constraints: c50945a9)
6-
com.diffplug.spotless:spotless-lib:2.41.0 (2 constraints: ea24c1e5)
7-
com.diffplug.spotless:spotless-lib-extra:2.41.0 (1 constraints: 47131c41)
8-
com.diffplug.spotless:spotless-plugin-gradle:6.21.0 (1 constraints: 3b054e3b)
9-
com.fasterxml.jackson.core:jackson-annotations:2.15.2 (2 constraints: c517c371)
10-
com.fasterxml.jackson.core:jackson-core:2.15.2 (5 constraints: 4a5dbc98)
11-
com.fasterxml.jackson.core:jackson-databind:2.15.2 (4 constraints: c14a9555)
12-
com.fasterxml.jackson.datatype:jackson-datatype-guava:2.15.2 (1 constraints: 3c05403b)
13-
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.15.2 (1 constraints: 3c05403b)
14-
com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.2 (1 constraints: 3c05403b)
15-
com.google.auto:auto-common:1.2.1 (2 constraints: 5a219b5a)
16-
com.google.auto.service:auto-service:1.1.1 (1 constraints: 0505f435)
17-
com.google.auto.service:auto-service-annotations:1.1.1 (1 constraints: 9c0f6a86)
2+
com.fasterxml.jackson.core:jackson-annotations:2.16.1 (2 constraints: 0f27a8e4)
3+
com.fasterxml.jackson.core:jackson-core:2.16.1 (5 constraints: 1b6b801e)
4+
com.fasterxml.jackson.core:jackson-databind:2.16.1 (5 constraints: cd5d2e54)
5+
com.fasterxml.jackson.datatype:jackson-datatype-guava:2.16.1 (1 constraints: 86142390)
6+
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.1 (1 constraints: 0d132339)
7+
com.fasterxml.jackson.module:jackson-module-parameter-names:2.16.1 (1 constraints: 0d132339)
188
com.google.code.findbugs:jsr305:3.0.2 (3 constraints: 571ca3f6)
19-
com.google.errorprone:error_prone_annotations:2.22.0 (4 constraints: 51279d7c)
20-
com.google.guava:failureaccess:1.0.1 (1 constraints: 140ae1b4)
21-
com.google.guava:guava:32.1.2-jre (7 constraints: 7e6ddaa1)
9+
com.google.errorprone:error_prone_annotations:2.23.0 (4 constraints: 4d27767b)
10+
com.google.guava:failureaccess:1.0.2 (1 constraints: 150ae2b4)
11+
com.google.guava:guava:33.0.0-jre (8 constraints: ec85ae15)
2212
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918)
2313
com.google.j2objc:j2objc-annotations:2.8 (2 constraints: 9716ab11)
24-
com.googlecode.concurrent-trees:concurrent-trees:2.6.1 (1 constraints: 761166da)
25-
com.googlecode.javaewah:JavaEWAH:1.2.3 (1 constraints: 460e7e50)
26-
com.squareup.okhttp3:okhttp:4.10.0 (1 constraints: f40938b3)
27-
com.squareup.okio:okio-jvm:3.0.0 (1 constraints: 4d0c26fd)
28-
dev.equo.ide:solstice:1.3.1 (1 constraints: 721158da)
29-
org.checkerframework:checker-qual:3.35.0 (3 constraints: 1b224228)
30-
org.derive4j:derive4j-annotation:1.1.1 (1 constraints: 0505f435)
31-
org.eclipse.jgit:org.eclipse.jgit:6.6.0.202305301015-r (2 constraints: da2a65d5)
32-
org.eclipse.platform:org.eclipse.osgi:3.18.300 (1 constraints: 5e0ad9c7)
33-
org.functionaljava:functionaljava:4.8 (1 constraints: b0042b2c)
34-
org.immutables:value:2.9.3 (1 constraints: 10051336)
35-
org.jetbrains:annotations:13.0 (1 constraints: df0e795c)
36-
org.jetbrains.kotlin:kotlin-stdlib:1.6.20 (3 constraints: 422e99b4)
37-
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.20 (2 constraints: 3c1b0a83)
38-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31 (1 constraints: e110f4d2)
39-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31 (1 constraints: fb0b19f9)
40-
org.slf4j:slf4j-api:1.7.36 (2 constraints: 801849c0)
41-
org.tukaani:xz:1.9 (1 constraints: 6b09e995)
14+
com.palantir.javaformat:palantir-java-format:2.44.0-3-gc5a0bc7.dirty (1 constraints: af0ab1bf)
15+
com.palantir.javaformat:palantir-java-format-spi:2.44.0-3-gc5a0bc7.dirty (1 constraints: 801882a8)
16+
org.checkerframework:checker-qual:3.41.0 (3 constraints: 1a22f927)
17+
org.functionaljava:functionaljava:4.8 (2 constraints: 3017b01b)
4218

4319
[Test dependencies]
44-
cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24)
20+
com.google.auto:auto-common:0.9 (1 constraints: be1116d7)
4521
com.google.auto.value:auto-value:1.5.3 (1 constraints: 1c121afb)
4622
com.google.auto.value:auto-value-annotations:1.10.1 (1 constraints: 8b0aa0c3)
4723
com.google.guava:guava-testlib:27.0.1-jre (1 constraints: aa067c53)
4824
com.google.testing.compile:compile-testing:0.15 (1 constraints: da04f230)
4925
com.google.truth:truth:1.1.5 (3 constraints: b92b54b9)
5026
com.google.truth.extensions:truth-java8-extension:0.37 (1 constraints: ef11ffe8)
51-
com.netflix.nebula:nebula-test:10.0.0 (1 constraints: 3305273b)
52-
junit:junit:4.13.2 (7 constraints: 796291b5)
27+
junit:junit:4.13.2 (5 constraints: 10444717)
5328
net.bytebuddy:byte-buddy:1.12.21 (1 constraints: 7d0bbfea)
54-
org.apiguardian:apiguardian-api:1.1.2 (7 constraints: 9d791b5f)
29+
org.apiguardian:apiguardian-api:1.1.2 (6 constraints: 24695e60)
5530
org.assertj:assertj-core:3.24.2 (1 constraints: 3d05473b)
56-
org.codehaus.groovy:groovy:3.0.6 (2 constraints: 1e1b476d)
57-
org.hamcrest:hamcrest:2.2 (1 constraints: d20cdc04)
5831
org.hamcrest:hamcrest-core:1.3 (1 constraints: cc05fe3f)
5932
org.junit.jupiter:junit-jupiter:5.10.0 (1 constraints: 3805413b)
6033
org.junit.jupiter:junit-jupiter-api:5.10.0 (4 constraints: 3145aef5)
6134
org.junit.jupiter:junit-jupiter-engine:5.10.0 (1 constraints: 330efd49)
6235
org.junit.jupiter:junit-jupiter-migrationsupport:5.10.0 (1 constraints: 3805413b)
6336
org.junit.jupiter:junit-jupiter-params:5.10.0 (1 constraints: 330efd49)
6437
org.junit.platform:junit-platform-commons:1.10.0 (2 constraints: 2b211983)
65-
org.junit.platform:junit-platform-engine:1.10.0 (3 constraints: ac2e4dc4)
66-
org.junit.vintage:junit-vintage-engine:5.10.0 (1 constraints: 3805413b)
67-
org.objenesis:objenesis:2.4 (1 constraints: ea0c8c0a)
38+
org.junit.platform:junit-platform-engine:1.10.0 (1 constraints: d210e4c4)
6839
org.opentest4j:opentest4j:1.3.0 (2 constraints: cf209249)
6940
org.ow2.asm:asm:9.5 (1 constraints: 080aaba4)
70-
org.spockframework:spock-core:2.0-M4-groovy-3.0 (2 constraints: e822d65a)
71-
org.spockframework:spock-junit4:2.0-M4-groovy-3.0 (1 constraints: 25115ddf)

versions.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ com.google.auto:auto-common:1.2.1 (2 constraints: b321cc9d)
1616
com.google.auto.service:auto-service:1.1.1 (1 constraints: 0505f435)
1717
com.google.auto.service:auto-service-annotations:1.1.1 (1 constraints: 9c0f6a86)
1818
com.google.code.findbugs:jsr305:3.0.2 (3 constraints: 571ca3f6)
19-
com.google.errorprone:error_prone_annotations:2.22.0 (4 constraints: 51279d7c)
20-
com.google.guava:failureaccess:1.0.1 (1 constraints: 140ae1b4)
21-
com.google.guava:guava:32.1.2-jre (7 constraints: 7e6ddaa1)
19+
com.google.errorprone:error_prone_annotations:2.24.1 (4 constraints: 49276b7b)
20+
com.google.guava:failureaccess:1.0.2 (1 constraints: 150ae2b4)
21+
com.google.guava:guava:33.0.0-jre (7 constraints: 156d100b)
2222
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918)
2323
com.google.j2objc:j2objc-annotations:2.8 (2 constraints: 9716ab11)
2424
com.googlecode.concurrent-trees:concurrent-trees:2.6.1 (1 constraints: 761166da)

0 commit comments

Comments
 (0)