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

fix: move comments in binaryExpression #353

Conversation

clementdessoude
Copy link
Contributor

Move comments before binaryOperator to the following unaryExpression

Fix #352

By comparison, what is done in Prettier for TS:

--parser typescript

Input:

a = one || two >> 1 // one
        // two
        // three
        || //four
        // five
        three;

Output:

a =
  one ||
  two >> 1 || // one //four
  // two
  // three
  // five
  three;

@clementdessoude
Copy link
Contributor Author

clementdessoude commented Dec 30, 2019

For the moment, there is still some unexpected behavior. But at least it is stable. For instance:

Input

public class InlineComment {

  public boolean method() {
    boolean a = one || two >> 1 // one
        // two
        // three
        || // five
        // four
        three;

        boolean a = one || two >> 1 // one
        // two
        // three
        ||
        three;

        boolean a = one || two >> 1 // one
        // two
        // three
        || three;
  }
}

Output

public class InlineComment {

  public boolean method() {
    boolean a =
      one ||
      two >> 1 || // one // five
      // two
      // three

      // four
      three;

    boolean a =
      one ||
      two >> 1 || // one
      // two
      // three

      three;

    boolean a =
      one ||
      two >> 1 || // one
      // two
      // three
      three;
  }
}

Move comments before binaryOperator to the following unaryExpression

remove single-printer-run modifications
@clementdessoude clementdessoude force-pushed the fix/comments-binaryExpressions branch from d0e4569 to 133c6c5 Compare January 3, 2020 17:42
@clementdessoude clementdessoude marked this pull request as ready for review January 3, 2020 17:43
@clementdessoude clementdessoude merged commit 5d525c5 into jhipster:master Jan 3, 2020
@clementdessoude clementdessoude deleted the fix/comments-binaryExpressions branch January 3, 2020 18:04
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.

Collapsing comments within expressions
1 participant