Skip to content

Less paranthesis - #195

Merged
phax merged 5 commits into
masterfrom
less-paranthesis
Sep 10, 2026
Merged

phax merged 5 commits into
masterfrom
less-paranthesis

Conversation

@phax

@phax phax commented Sep 10, 2026

Copy link
Copy Markdown
Owner

As the follow-up on #183

glelouet and others added 4 commits September 10, 2026 15:26
* Add precedence in IGenerable

JOp has enum Precedence. First one has higher priority.

IGenerable defaults to TOKEN precedence.

unary, binary, ternary operator have that value replaced with the one of
their operator.

Cast, array comp redefine that value with their own precedence.

FormatterSetting has option for parentheses.operator :
 - ALWAYS to add all the parenthesis we can
 - NONTOKEN to only skip token parts
 - REQUIRED to only parenthesis around element with lower precedence

Previously mentioned elements use that value to add () when needed.

This is formatting, yet some behavior should be the same in the end
whatever formatting we choose : there are test classes to obv. showcase
and track the changes, but also actually test the behavior.

* added example module to have settings defaults

* spreading tests and use functional interface.

* wording, RuntimeException->UncheckedIoException

* jfor javadoc, more parentheses tests

* parentheses settings rename from "operators" to "global"

---------

Co-authored-by: glelouet <n@mo>
@phax phax self-assigned this Sep 10, 2026
@phax
phax merged commit 9151d03 into master Sep 10, 2026
7 checks passed
@phax
phax deleted the less-paranthesis branch September 10, 2026 15:56
@phax

phax commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

@glelouet as usual, I don't see your comments on the commit 25f328d

Please repost here

@glelouet

Copy link
Copy Markdown
Collaborator

@phax that's annoying.

There was several comments

  1. you gave precedence 15 to assignment and lambda which is incorrect : l = a -> f=a is l = a -> (f=a). This happened because you replace the call to ordinal() with an internal field that is the ordinal … please revert to ordinal.

  2. in the generated test classes, with the always settings, some parenthesis disappeared. They should not.

@phax

phax commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

@glelouet please recheck master

@glelouet

glelouet commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

@phax lgtm

Though What I said was actually wrong, I need to make a few tests.
Consumer<Object> co = o->myField=o ; has two assignement, yet the actual parenthesized would be co=(o->(myfield=o)) ;

@phax

phax commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner Author

So I am on vacation and most likely can't do a release built in-between....

@glelouet

Copy link
Copy Markdown
Collaborator

That gives me some time for the next PR … :evil_face:

@phax

phax commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Evil face does not render on GitHub - sorry ;-)

@phax

phax commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner Author

Btw for that feature I really recommend test driven development - there are so many permutations

@glelouet

Copy link
Copy Markdown
Collaborator

nah, it's actually just a bit of code. But please give your advice in the corresponding PR :-D :very_evil_face:

@phax

phax commented Sep 24, 2026

Copy link
Copy Markdown
Owner Author

@glelouet do you intent to do anything additional on this matter?

@glelouet

Copy link
Copy Markdown
Collaborator

@phax ? No ?

@phax

phax commented Sep 24, 2026

Copy link
Copy Markdown
Owner Author

good :)

@phax

phax commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

For the record - there was already a followup in #197

phax added a commit that referenced this pull request Sep 25, 2026
@glelouet

Copy link
Copy Markdown
Collaborator

Yes, that was fixing a specific issue, I looked at the code and there was too many changes to I trust you instead.

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 participants