Bug 537121 - Formatter splits lines with static prefix unnecessarily
Summary: Formatter splits lines with static prefix unnecessarily
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2018-07-17 16:28 EDT by Martin Spamer CLA
Modified: 2018-10-10 12:02 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Spamer CLA 2018-07-17 16:28:24 EDT
The formatter is unnecessarily splitting lines that includes a static references, the following line is split.

    private static final Logger LOG = LoggerFactory.getLogger(ClassFactory.class);

is changed to

    private static final Logger LOG = LoggerFactory
        .getLogger(ClassFactory.class);

Changing the maximum line length from 80 to 160 makes no difference, (the line is 86 characters long).

Preference ->Code Style -> Formatter does not include any clear option to stop the formatting of static prefixes.
Comment 1 Mateusz Matela CLA 2018-07-18 17:08:27 EDT
The formatter doesn't know which references are static (it doesn't resolve AST bindings). So the relevant wrapping setting for your example is "Qualified invocations".
Does that resolve your issue?
Comment 2 Martin Spamer CLA 2018-08-01 08:03:17 EDT
Setting both 'Qualified invocations' to 'do not wrap' and it still wraps this unnecessarily.
Comment 3 Mateusz Matela CLA 2018-08-04 07:53:41 EDT
What do you mean *both* 'Qualified invocations'? There's only one setting named like that.