Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid adding space on // comments? #1217

Open
maxandersen opened this issue Jan 7, 2025 · 2 comments
Open

avoid adding space on // comments? #1217

maxandersen opened this issue Jan 7, 2025 · 2 comments

Comments

@maxandersen
Copy link

maxandersen commented Jan 7, 2025

its a special case but in jbang I use //JAVA , //DEPS etc as special markers.

I tried using @Formatter:off but seem to have no effect.

///usr/bin/env jbang "$0" "$@" ; exit $?
// @formatter:off
//JAVA 21+
//PREVIEW
//DEPS org.imgscalr:imgscalr-lib:4.2

class test {

}

gets turned into:

/// usr/bin/env jbang "$0" "$@" ; exit $?
// @formatter:off
// JAVA 21+
// PREVIEW
// DEPS org.imgscalr:imgscalr-lib:4.2

the first line is a case of #1218 but the others below - how does one tell google-java-format not to mess with those?

@tbroyer
Copy link
Contributor

tbroyer commented Jan 7, 2025

@vorburger
Copy link
Member

vorburger commented Jan 10, 2025

@maxandersen FYI the first problem (///usr/bin/env jbang ...) is what I previously raised #1215 about, perhaps you would like to Subscribe (Watch) that issue, engage on it if you have anything to add (there's an "interesting" question re. JEP 467 Markdown JavaDoc...), or perhaps even consider contributing?

The other part, re. //JAVA 21+ to // JAVA 21+ etc. is interesting, and perhaps what this issue should be about. How (what "algorithm") would a formatter "know" that it should not touch such lines - but that it does need to insert a space in something like //this function...\nvoid foo(); - what "rule" identifies this case? It "feels" like a very specific convention - but perhaps you know how other code formatting tools (Checkstyle?) handle this?

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

No branches or pull requests

3 participants