Skip to content

fix: keep package declaration with annotations before import declarations#913

Merged
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/package-before-imports
May 28, 2026
Merged

fix: keep package declaration with annotations before import declarations#913
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/package-before-imports

Conversation

@jtkiesel
Copy link
Copy Markdown
Contributor

What changed with this PR:

Package declarations with multiple annotations are no longer moved after import declarations. This was actually caused by a bug with the tree-sitter Java grammar, which thinks the package declaration with multiple annotations is a local variable declaration, but it was easy enough to work around here.

Example

Input

@A
@B
package a;

import a.A;
import b.B;

Output

@A
@B
package a;

import a.A;
import b.B;

Relative issues or prs:

Closes #910

@jtkiesel jtkiesel merged commit 159476a into jhipster:main May 28, 2026
6 checks passed
@jtkiesel jtkiesel deleted the fix/package-before-imports branch May 28, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spotless-specific: package-info.java with multiple annotations loses "package" statement

1 participant