What did I break in my Eclipse formatter?

49 views Asked by At

Recently lost a dev machine and I just can't seem to get my formatter back to how it worked before. I've gotten it really close but there's a few things where I just can't figure out what the formatter setting is to fix it!

Before

public void method1() {
    MyObject myObject = 
        MyObject
            .builder()
            .param1(param1)
            .param2(param2)
            .param3(param3)
            .build();
}

After

public void method1() {
    MyObject myObject = MyObject
        .builder()
        .param1(param1)
        .param2(param2)
        .param3(param3)
        .build();
}

Before

public void method2() {
    mySomewhatLongName.methodName(somewhatLongMethod(myObject.getParam1(),
            myObject.getParam2);
}

After

public void method2() {
    mySomewhatLongName
            .methodName(somewhatLongMethod(myObject.getParam1(),myObject.getParam2);
}

Before

public void method3() {
    SomeEnumVariable someLongerObject =
            StringUtils.isNotEmpty(someString) ? SomeEnumVariable.VALUE_1
                    : SomeEnumVariable.VALUE_1;
}

After

public void method3() {
    SomeEnumVariable someLongerObject = StringUtils.isNotEmpty(someString)
            ? SomeEnumVariable.VALUE_1 : SomeEnumVariable.VALUE_1;
}

I know formatting isn't a big deal but my CRs are just all my autoformatter annihilating existing code and I just want to fix this.

1

There are 1 answers

3
Badasahog On

You can reset formatting settings by going to project > properties > Java Code Style > Formatter

Enable Project-specific settings, and change your active profile to Eclipse [built-in]

You can also create your own formatting settings, if you want.