Fix expression print#223
Merged
clementdessoude merged 10 commits intojhipster:masterfrom Jun 21, 2019
Merged
Conversation
clementdessoude
requested changes
Jun 20, 2019
packages/prettier-plugin-java/test/unit-test/binary_expressions/_output.java
Outdated
Show resolved
Hide resolved
Contributor
|
Shouldn't the catch Clause be updated too? |
Contributor
|
Maybe also add some test case which should not break? Like: if (test1 == true && test2 != null) |
Member
Author
This is already handled by a different "rule", but it add the try {} catch (
Exception
| Exception
| Exception
| Exception
| Exception
| Exception
| Exception
| Exception
| Exception
| Exception e
) {}This one is recognized. try {} catch (
Exception |
Exception |
Exception |
Exception |
Exception |
Exception |
Exception |
Exception |
Exception |
Exception e
) {}Not this one. |
Member
Author
|
this looks good now. Example: if(test == 1 && test == 1 && test == 1 && test == 1 && test == 1 && test == 1 && test == 1 && test == 1 && test == 1 && mljkejkoerjkotjerjtlejlrtj == elkrjtklerjtklejklrtjkeljtklejklrtjklejrtkljeklrjtklejrkltjelkrtjl) {
}output: if (
test == 1 &&
test == 1 &&
test == 1 &&
test == 1 &&
test == 1 &&
test == 1 &&
test == 1 &&
test == 1 &&
test == 1 &&
mljkejkoerjkotjerjtlejlrtj ==
elkrjtklerjtklejklrtjkeljtklejklrtjklejrtkljeklrjtklejrkltjelkrtjl
) {} |
clementdessoude
approved these changes
Jun 21, 2019
Contributor
clementdessoude
left a comment
There was a problem hiding this comment.
Just a little comment, but LGTM.
I find the binary expression code much cleaner now 👍
| const { groups, sortedBinOps } = separateTokensIntoGroups(ctx); | ||
| const allSegment = []; | ||
| let tmpSegment = []; | ||
|
|
Contributor
There was a problem hiding this comment.
I would try to clarify what those variables mean.
Maybe:
- groupsOfOperator instead of groups,
- sortedBinaryOperators instead of sortedBinOps,
- segmentsSplittedByBinaryOperator instead of allSegments
- currentSegment instead of tmpSegment
WDYT?
Member
Author
There was a problem hiding this comment.
yep those variables fits it better 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the breaking expression discussed here
Example:
input:
output:
However, it will only breaks on && and ||.if we have
if(aVeryVeryVeryVeryVeryVeryVeryVeryVeryLongVariable == aVeryVeryVeryVeryVeryVeryVeryVeryVeryLongVariable2), it won't break on==.Is it bothersome ? I am not sure... It will be hard to tell how we should break each operator since we just have an array on all operators on the cstnode.
I am working with @clement26695 to make it work 👍