INRIA / INRIA/spoon

extraneous parenthesis at pretty-printing, should take into account operator precedence

Open
#3,809 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2k
Forks
393
Avg merge
11h 24m
Merged PRs (30d)
36

Description

We all know that Spoon is generous at putting parentheses, in particular for binary operators and cast expressions.

One way to solve this is to use the implicit information from CTElement to signal parenthesis to be written:

CtBinaryOperator.isImplicit() == true => no parentheses required
CtBinaryOperator.isImplicit() == false => parentheses required

See also the discussion about sniper at https://github.com/INRIA/spoon/issues/3794

Contributor guide

Open the contributing guide

Research direction

Start by reading the CtBinaryOperator and CTElement APIs, then review the discussion in issue #3794 about sniper. Trace how pretty-printing handles binary operators and cast expressions, especially operator precedence and the isImplicit() signal. Done means generated Java no longer contains unnecessary parentheses while preserving required grouping.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.