Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 456425 - Off/On tags don't work correctly together with Save Actions
Summary: Off/On tags don't work correctly together with Save Actions
Status: VERIFIED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4.1   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 4.17 M1   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-31 10:59 EST by Patrick Gotthard CLA
Modified: 2020-07-08 21:59 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 Patrick Gotthard CLA 2014-12-31 10:59:30 EST
Since some versions (I think since intoducing support for Lambda expressions) the On/Off tags don't work correctly together with Save Actions.

Use the following code as example:

public class Example {

    private final String propertyA;
    private final String propertyB;

    private Example(final Builder builder) {
        propertyA = builder.propertyA;
        propertyB = builder.propertyB;
    }

    public String getPropertyA() {
        return propertyA;
    }

    public String getPropertyB() {
        return propertyB;
    }

    public static class Builder {

        private String propertyA;
        private String propertyB;

        public Builder setPropertyA(final String propertyA) {
            this.propertyA = propertyA;
            return this;
        }

        public Builder setPropertyB(final String propertyB) {
            this.propertyB = propertyB;
            return this;
        }

        public Example build() {
            return new Example(this);
        }

    }

    public static void main(final String[] args) {
        // @formatter:off
        final Example example = new Example.Builder()
            .setPropertyA("A")
            .setPropertyB("A")
            .build();
        // @formatter:on
    }

}

Just formatting the code leaves the main method "as-is", while pressing Strg + S (the "format all lines" save action is activated) the code gets formatted:

    public static void main(final String[] args) {
        // @formatter:off
        final Example example = new Example.Builder()
        .setPropertyA("A")
        .setPropertyB("A")
        .build();
        // @formatter:on
    }
Comment 1 Patrick Gotthard CLA 2015-06-02 11:42:11 EDT
Any progress here?
Comment 2 Eclipse Genie CLA 2020-05-30 13:53:03 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Mateusz Matela CLA 2020-05-30 15:39:07 EDT
Tested wit 4.5, it seems this problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 4 Manoj N Palat CLA 2020-07-08 21:56:14 EDT
Verified for Eclipse Version: 2020-09 (4.17) M1 with Build id: I20200707-1800