Skip to content

Feat: Use JBang-fmt to format sources#1945

Open
cstamas wants to merge 6 commits into
eclipse-openvsx:mainfrom
cstamas:jbang-fmt
Open

Feat: Use JBang-fmt to format sources#1945
cstamas wants to merge 6 commits into
eclipse-openvsx:mainfrom
cstamas:jbang-fmt

Conversation

@cstamas

@cstamas cstamas commented Jul 6, 2026

Copy link
Copy Markdown
Member

This can be easily incorporated into git commit hooks as well.

See https://github.com/jbangdev/jbang-fmt

This is "bare minimum" setup, to format only main and test Java sources of server (excluding jOOQ generated ones).

Once we format, initial formatting will need a "source format" commit without any other code change, and add that commit hash to .git-blame-ignore-revs file in repo root to fix blame.

Git integration doco:
https://github.com/jbangdev/jbang-fmt#git-integration

cstamas and others added 3 commits July 6, 2026 11:50
This can be easily incorporated into git commit hooks as well.

See https://github.com/jbangdev/jbang-fmt

This is "bare minimum" setup, to format only main and test
Java sources of server (excluding jOOQ generated ones).

Once we format, initial formatting will need a "source format"
commit without any other code change, and add that commit hash
to `.git-blame-ignore-revs` file in repo root to fix blame.
@netomi netomi marked this pull request as ready for review July 15, 2026 12:17
@netomi

netomi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

I did update the used format to a custom eclipse format with some modifications that I would prefer.
Please take a look, there is a script in server/scripts/format.sh to format the sources.

I am not happy with the array initializers. The closing bracket is not on a new line when wrapping, but that does not seem to be supported by the eclipse format. Either always have the closing bracket or not, there is no option to conditionally add it to a new line depending on whether it was wrapped.

There are a few occurrences in the code I do not really like but it looks like 99% of the other cases are fine.

wdyt @cstamas @gnugomez @autumnfound ?

you can just run server/scripts/format.sh and do a git diff

@netomi

netomi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

this format is as close as possible to the existing formatting that is currently used afaict.

@cstamas

cstamas commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

I like it! And make it applied as soon as possible!

@netomi

netomi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

I also added an sort import step using spotless which is run via jbang as the eclipse formatter does not support that unfortunately.

as there is no cli, claude came up with a small java file to run the ImportOrder step on all the source files that can be executed with jbang.

pretty neat imho. I pefer the following order:

// Import order: java/javax first, then everything else, then org.eclipse.openvsx,
// then static imports, each group separated by a blank line.
"java|javax", "", "org.eclipse.openvsx", "\\#"

@netomi

netomi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

btw. created eclipse-jdt/eclipse.jdt.core#5195 for the issue in the eclipse formatter that it can not place the closing brace of an array initializer on a new line if its wraps.

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.

2 participants