Skip to content

fix: restore comment attachment to formal parameters, including JSNI comments#963

Merged
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/formal-parameters-comments
Jun 30, 2026
Merged

fix: restore comment attachment to formal parameters, including JSNI comments#963
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/formal-parameters-comments

Conversation

@jtkiesel

Copy link
Copy Markdown
Contributor

What changed with this PR:

Prettier is allowed to attach comments to formal parameters nodes again. Printing of comments inside of empty formal parameters is also aligned more closely with Prettier JS/TS again.

Note that JSNI comments still cause the method definition's parameter list to be wrapped. This is not ideal, but is the way it was working previously, so this PR will be merged to restore JSNI support and a follow-on effort can attempt to fix the forced wrapping issue.

Example

Input

class JSNI {
  private native JsArray<MyItem> getItems() /*-{
    return this.items
  }-*/;

  private static native void registerHandler(MyHandler handler) /*-{
    $doc.addEventListener("visibilitychange", function () {
      handler.@com.example.MyHandler::onEvent()();
    });
  }-*/;
}

class DanglingComments {

  void two(
    // alpha
  ) {}

  void three(
    // alpha
    // beta
  ) {}

  void four(
    // alpha
    // beta
    /* gamma */
  ) {}

  void five( // alpha
  ) {}

  void six(/* alpha */) {}

  void seven(
    /* alpha */
    /* beta */
  ) {}

  void eight(
    /* alpha */
    // beta
  ) {}

  void nine(
  /* alpha */
  ) {}

  void two(
    String one
    // alpha
  ) {}

  void three(
    String one
    // alpha
    // beta
  ) {}

  void four(
    // alpha
    String one
    // beta
    /* gamma */
  ) {}

  void seven(
    /* alpha */
    String one
    /* beta */
  ) {}

  void eight(
    /* alpha */
    String one
    // beta
  ) {}

  void nine(String one
  /* alpha */
  ) {}
}

Output

class JSNI {

  private native JsArray<MyItem> getItems() /*-{
    return this.items
  }-*/;

  private static native void registerHandler(
    MyHandler handler
  ) /*-{
    $doc.addEventListener("visibilitychange", function () {
      handler.@com.example.MyHandler::onEvent()();
    });
  }-*/;
}

class DanglingComments {

  void two(
    // alpha
  ) {}

  void three(
    // alpha
    // beta
  ) {}

  void four(
    // alpha
    // beta
    /* gamma */
  ) {}

  void five(
    // alpha
  ) {}

  void six(/* alpha */) {}

  void seven(
    /* alpha */
    /* beta */
  ) {}

  void eight(
    /* alpha */
    // beta
  ) {}

  void nine(/* alpha */) {}

  void two(
    String one
    // alpha
  ) {}

  void three(
    String one
    // alpha
    // beta
  ) {}

  void four(
    // alpha
    String one
    // beta
    /* gamma */
  ) {}

  void seven(
    /* alpha */
    String one
    /* beta */
  ) {}

  void eight(
    /* alpha */
    String one
    // beta
  ) {}

  void nine(
    String one
    /* alpha */
  ) {}
}

Relative issues or prs:

Closes #957

@jtkiesel jtkiesel changed the title fix: restore support for comments on formal parameters, including JSNI comments fix: restore comment attachment to formal parameters, including JSNI comments Jun 30, 2026
@jtkiesel jtkiesel merged commit cd2a838 into jhipster:main Jun 30, 2026
6 checks passed
@jtkiesel jtkiesel deleted the fix/formal-parameters-comments branch June 30, 2026 03:08
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.9.7] native GWT JSNI methods get a spurious () appended after }-*/, breaking compilation

1 participant