Use Palantir Java Format - #12421
Draft
bric3 wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Switches every Spotless Java configuration from google-java-format 1.36.1 to palantir-java-format 2.97.0 and explicitly selects
.style("GOOGLE").It also updates the contributor and agent guides, including the IntelliJ setup.
Representative Formatting Changes
These examples come from the repository sources reformatted in #12422.
Compact Lambda Pipelines
PluginApplication.javaVertically Aligned Fluent Calls
AdviceGeneratorImpl.javaNested Callbacks Without an Indentation Pyramid
CoreTracer.javaNested Lambda Pipelines Without Stair-Step Indentation
AssertBuilder.javareturn type.getAnnotationByName("AutoService") - .<Set<Class<?>>>map( - annotation -> - annotation.asNormalAnnotationExpr().getPairs().stream() - .filter(pair -> pair.getNameAsString().equals("value")) - .flatMap( - pair -> - pair.getValue().asArrayInitializerExpr().getValues().stream() - .map( - value -> - value - .asClassExpr() - .getType() - .resolve() - .asReferenceType() - .getTypeDeclaration() - .get() - .getQualifiedName())) - .map(AssertBuilder::loadClass) - .collect(Collectors.toSet())) + .<Set<Class<?>>>map(annotation -> annotation.asNormalAnnotationExpr().getPairs().stream() + .filter(pair -> pair.getNameAsString().equals("value")) + .flatMap(pair -> pair.getValue().asArrayInitializerExpr().getValues().stream() + .map(value -> value + .asClassExpr() + .getType() + .resolve() + .asReferenceType() + .getTypeDeclaration() + .get() + .getQualifiedName())) + .map(AssertBuilder::loadClass) + .collect(Collectors.toSet())) .orElse(Collections.emptySet());Switch Blocks Attached to Their Labels
JsonToExpressionConverter.javaMotivation
The experiment deliberately selects
GOOGLEstyle to preserve the repository's existing two-space indentation and 100-character line width. This keeps the evaluation focused on Palantir's lambda and fluent-chain layout instead of combining it with a repository-wide indentation and line-width change. It also reduces the stacked reformat from 6,133 files with the defaultPALANTIRstyle to 1,855 files.Additional Notes
This is the base of a two-PR experiment.
spotlessCheckis expected to report Java format violations on this PR alone; the stacked reformatting PR #12422 makes the new formatter idempotent.The Palantir IntelliJ plugin currently exposes only the default
PALANTIRstyle, so the contributor guide keeps the Spotless Gradle tasks as the formatting source of truth for thisGOOGLE-style experiment.Palantir 2.97.0 with
GOOGLEstyle keeps the closing parenthesis beside the final parameter:Spotless exposes Palantir style and Javadoc options, but no independent indentation or closing-parenthesis option.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue