palantir-java-format
palantir-java-format copied to clipboard
Improve formatting for stacked annotations
What happened?
public void foo(
@FirstAnnotation(value = SOME_CONSTANT, another = "string")
@SecondAnnotation(
something = SOME_CONSTANT,
array = {"one", "two", "three"})
@ThirdAnnotation("value")
MyType whatever,
MyOtherType somethingElse) {
}
It's a bit difficult to see why it got formatted this way?
What did you want to happen?
public void foo(
@FirstAnnotation(value = SOME_CONSTANT, another = "string")
@SecondAnnotation(
something = SOME_CONSTANT,
array = {"one", "two", "three"})
@ThirdAnnotation("value")
MyType whatever,
MyOtherType somethingElse) {
}
When a parameter has multiple annotations, I'd like them to be aligned to the left.
IMHO this would be an improvement. Want to submit a pr?
@robert3005 can you provide some guidance on how to get that implemented? I'm also interested.
Not sure I can give you more beyond - start with a test case in https://github.com/palantir/palantir-java-format/tree/develop/palantir-java-format/src/test/resources/com/palantir/javaformat/java/testdata and from there figure out where the formatter decides to add new indentation level
I think I prefer it the way it is, personally. You can scan the first column of the parameters and easily see their number / where each one's definition begins. With your desired example you have to take a moment (however short) to see if it's another annotation or not.