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 - Allow "Formatting > Blank Lines" to set attribute to "ignore"
Summary: Allow "Formatting > Blank Lines" to set attribute to "ignore"
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-27 02:18 UTC by brettryan
Modified: 2015-09-16 07:06 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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".