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 254428 - Continuation indentation size to open constructor/method bracket
Summary: Continuation indentation size to open constructor/method bracket
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0.2
Hardware: PC All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-17 11:02 UTC by Alexandr Scherbatiy
Modified: 2016-04-25 18:12 UTC (History)
1 user (show)

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 Alexandr Scherbatiy 2015-08-17 11:02:23 UTC
NetBeans preferences allows to set only continuation indentation size.

There is a code style in JDK project that the continuation indentation for constructor or method arguments should be below open '(' bracket.

For example:
java.awt.GraphicsConfiguration class:
-----------------
    public BufferedImage createCompatibleImage(int width, int height,
                                               int transparency)
    {
-----------------

The argument which is printed on new line is placed under the '(' bracket.

Could this option be added to the NetBeans settings?
Comment 1 Alexandr Scherbatiy 2015-08-17 11:27:45 UTC
Found an example in Code Conventions for the Java Programming Language:
  http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-136091.html#248

Following are two examples of indenting method declarations. The first is the conventional case. The second would shift the second and third lines to the far right if it used conventional indentation, so instead it indents only 8 spaces.

    //CONVENTIONAL INDENTATION
    someMethod(int anArg, Object anotherArg, String yetAnotherArg,
               Object andStillAnother) {
        ...
    }

    //INDENT 8 SPACES TO AVOID VERY DEEP INDENTS
    private static synchronized horkingLongMethodName(int anArg,
            Object anotherArg, String yetAnotherArg,
            Object andStillAnother) {
        ...
    }


The request for this enhancement is for the first case.
Comment 2 matthies 2016-04-25 16:58:02 UTC
FWIW, I would recommend the following each-parameter-on-its-own-line indentation style for long parameter lists, which works fine with the current NB feature set and is always very readable:

    public void someMethod(
        int anArg,
        Object anotherArg,
        String yetAnotherArg,
        Object andStillAnother)
    {
        ...
    }
Comment 3 Alexandr Scherbatiy 2016-04-25 18:12:22 UTC
new Java Style Guidelines (Draft) also describes the requested indentation as one of possible options:
http://cr.openjdk.java.net/~alundblad/styleguide/

    Variant 1: With 8 extra spaces relative to the indentation of the previous line.
    Variant 2: With 8 extra spaces relative to the starting column of the wrapped expression.
    Variant 3: Aligned with previous sibling expression (as long as it is clear that it’s a continuation line)
    Variant 4: Aligned with previous method call in a chained expression.
--------------
// Variant 3
int anInteger = aMethod(thatTakes,
                        aLongList,
                        ofArguments);
--------------

It would be good if NetBeans supports all of them.


The reason that I ask to add this option is because it is required indentation convention in java 2D team which we need to follow in review process.

For example see java.awt.Graphics class:
http://hg.openjdk.java.net/jdk9/client/jdk/file/fe8df8e55825/src/java.desktop/share/classes/java/awt/Graphics.java
----------------
    public abstract boolean drawImage(Image img, int x, int y,
                                      int width, int height,
                                      ImageObserver observer);
----------------