Fix annotation and record declaration header not applying continuation indent to wrapped annotations#22
Conversation
This brings it in line with other declarations. Adds more test coverage: classes, enums.
This is not as simple as with annotation declarations. All other declarations call `buildTypeHeader`, but records have their own `buildRecordHeader`. Both of these methods needs to do the same thing relative to annotations on the type.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…params The tail composite (type + name after an annotation) shared its `WhiteSpace` object with the first leaf. Then `applySpacing` zeroed `indentSpaces` on that shared object, and passing true as `usesFirstChildIndentAsBlockIndent` caused the walk to short-circuit there, reading the zeroed value (column 0) instead of the correct column from RecordComponent (column 8). Passing false as `canUseFirstChildIndent` forces the walk to continue up to RecordComponent which still holds the correct `indentSpaces`.
There was a problem hiding this comment.
Pull request overview
Aligns Java declaration header formatting so wrapped annotation argument lists keep continuation indent consistently for annotation type declarations and record declarations (which use a separate buildRecordHeader path), matching behavior already used for other declarations.
Changes:
- Route
AnnotationTypeDeclarationheader building throughbuildTypeHeader(...)so wrapped annotations are decomposed and their wrapped values retain continuation indent. - Update
buildRecordHeader(...)to decompose wrapped annotations in the prefix (up to() viaemitPrefixWithAnnotations(...), ensuring wrapped annotation values keep continuation indent. - Add regression tests covering class, annotation, record, record component, and enum declarations with wrapped annotations / wrapped params.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| airstyle-core/src/main/java/io/airlift/airstyle/engine/java/JavaDeclarationBuilder.java | Fixes header construction for annotation type + record declarations to decompose wrapped annotations and preserve continuation indent behavior. |
| airstyle-core/src/test/java/io/airlift/airstyle/TestAnnotationUseStyleFormatting.java | Adds regression tests for wrapped-annotation continuation indent across more declaration kinds (class/enum/record/etc.). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
For annotation declarations, this brings it in line with other declarations. For record declarations this is slightly different, as all other declarations call
buildTypeHeader, but records have their ownbuildRecordHeader. Both of these methods needs to do the same thing relative to annotations on the type.The third commit fixes a related issue, but not exactly the same. It's included in the same PR as the others mostly because the test cases would otherwise get into conflict with test cases from other commits.
Adds more test coverage: classes, enums.