Environment
- prettier-plugin-java: 2.10.1
- prettier: 3.8.3
- JDK used to compile output: 21.0.10
Execution
"format": "prettier \"**/*.(yaml|yml|md|ts|tsx|java)\" --write"
Description
When formatting a GWT JSNI native method, the plugin inserts an extra () between the closing JSNI delimiter }-*/ and the terminating semicolon. This corrupts the JSNI block and causes the GWT compiler to fail:
[ERROR] <no source info>: <source info not available>
[ERROR] at XX.java(91): XXX.getInitiator()Ljava/lang/String;
com.google.gwt.dev.jjs.ast.JMethod
This worked correctly before 2.9.7 (tested in 2.8.1) and is still broken in 2.10.1 (tested).
Input
private native JsArray<MyItem> getItems() /*-{
return this.items
}-*/;
private static native void registerHandler(
MyHandler handler
) /*-{
$doc.addEventListener("visibilitychange", function () {
handler.@com.example.MyHandler::onEvent()();
});
}-*/;
Actual output (does not compile)
private native JsArray<MyItem> getItems() /*-{
return this.items
}-*/();
private static native void registerHandler(
MyHandler handler /*-{
$doc.addEventListener("visibilitychange", function () {
handler.@com.example.MyHandler::onEvent()();
});
}-*/
);
Expected output
Identical to the input — the JSNI block must be left untouched and no () should be added.
Environment
Execution
"format": "prettier \"**/*.(yaml|yml|md|ts|tsx|java)\" --write"Description
When formatting a GWT JSNI native method, the plugin inserts an extra
()between the closing JSNI delimiter}-*/and the terminating semicolon. This corrupts the JSNI block and causes the GWT compiler to fail:This worked correctly before 2.9.7 (tested in 2.8.1) and is still broken in 2.10.1 (tested).
Input
Actual output (does not compile)
Expected output
Identical to the input — the JSNI block must be left untouched and no () should be added.