This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 217434

Summary: Allow "Formatting > Blank Lines" to set attribute to "ignore"
Product: java Reporter: brettryan <brettryan>
Component: EditorAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.2   
Hardware: All   
OS: All   
See Also: https://netbeans.org/bugzilla/show_bug.cgi?id=255313
Issue Type: ENHANCEMENT Exception Reporter:

Description brettryan 2012-08-27 02:18:14 UTC
In most cases the formatting works fine, however in some cases you'd just like to set it to "ignore" to allow you to manually control the white-space, sometimes it's not black and white.

As an example, given a class which only contains constant definitions.

public class MyConstants {

    public static final String SETTING1 = "s1";
    public static final String SETTING2 = "s2";

}

If you set "After Field" to "0" it will remove any blank lines after this field. Setting it to 1, will fix the line before the class is closed, but it will cause a new line in between the two constants which is undesired.

Also consider the following:

public class MyClass {

    public void sortMe(List l) {
        Collections.sort(l, new Comparator() {
            @Override
            public int compare(Object t, Object t1) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
    }

    public void doOther() {
    }

}

Having "After Method" set to "1" renders thusly.


public class MyClass {

    public void sortMe(List l) {
        Collections.sort(l, new Comparator() {
            @Override
            public int compare(Object t, Object t1) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

        });
    }

    public void doOther() {
    }

}

However having it set to "0" yields the following.

public class MyClass {

    public void sortMe(List l) {
        Collections.sort(l, new Comparator() {
            @Override
            public int compare(Object t, Object t1) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
    }

    public void doOther() {
    }
}

So I get around this by setting "Before Method" to "1" and "After Method" to "1", this produces the following:

public class MyClass {

    public void sortMe(List l) {
        Collections.sort(l, new Comparator() {

            @Override
            public int compare(Object t, Object t1) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

        });
    }

    public void doOther() {
    }

}

I don't want a single method anonymous reference to be padded with new-lines but I can't win and this is the best I can think of.

I would prefer to somehow override this by setting it to -1 to tell NetBeans to ignore this processor.
Comment 1 brettryan 2012-08-27 02:20:57 UTC
Actually, in my last example you need to also set "After Anonymous Class Header" to "1".