Bug 544148 - Support formatting in blocks (lambda) with unbalanced brackets
Summary: Support formatting in blocks (lambda) with unbalanced brackets
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.10   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2019-02-05 12:51 EST by Mickael Istria CLA
Modified: 2019-07-28 06:55 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2019-02-05 12:51:35 EST
While developing with lots of lambdas and brackets are unbalanced, Eclipse JDT produces an error message for a missing bracket that spans over 4 lines and 20 instructions. This makes it quite hard to remediate the issue.
When developing without auto-formatting, my strategy to deal with it is to rely on the formatting to better highlight which blocks have unbalanced brackets. It's useful.
However, when a project has format on save, it screws up the manual formatting to something that's much less helpful and making remediation of unbalanced brackets harder to troubleshoot.
It would be great if the formatter would be more able to deal with such cases, by at least formatting according to the opening bracket, or fully skipping formatting for blocks which aren't syntaxically correct.
Comment 1 Dani Megert CLA 2019-02-09 11:43:34 EST
Wouldn't it be better to provide better support to deal with the reported error than tweaking the formatter?
Comment 2 Mateusz Matela CLA 2019-07-27 19:55:19 EDT
Also, the formatter does skip formatting for any nodes that are marked as malformed. Usually it means whole methods that contain any syntax error.
Can you give an example of a malformed code that gets formatted?