-
Notifications
You must be signed in to change notification settings - Fork 464
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
Formatting inception - Extract blocks from a file, and apply different formatters on them than the rest of the file #412
Comments
Which formatter are you using? Spotless has two js formatters, eclipseWtp and prettier. |
Oh, I forgot to mention the main thing. It's Java, where the JS could be written inline. So the code looks like this:
Inside of |
Ahh, okay. So you want to format javascript within the comment blocks of java code. There's two main paths you can take. One is to file a feature request with one of our java formatters (either google-java-format or eclipse), and get them to add this feature. Once they had implemented the feature, you could use it with any of Spotless' plugins. That's out-of-scope for Spotless, you'll have to file an issue with the formatter library itself. A more flexible way to do this is for Spotless to have the general ability to extract blocks from the text, and apply a chain of formatters to them, which could work like this: spotless {
java {
eclipse()
withinBlocks('gwtJavascript', '/*-{', '}-*/') {
eclipseWtp('js')
}
}
} This would create a step called
|
I tried it with your extract block like this:
But I get this error: |
Yep. |
#691 makes this issue relatively easy to implement now. |
Shipped in |
The Google Web Toolkit provides with the JavaScript Native Interface an option to write inline JavaScript. The current formatter indents this native code on one level. It would be nice if it would be formatted like the normal JavaScript code or an extra option would also be fine.
You can find more information about the syntax here
The text was updated successfully, but these errors were encountered: