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 231874 - NetBeans editor should have nested continuation indentation
Summary: NetBeans editor should have nested continuation indentation
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.3.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-26 21:38 UTC by Michel Graciano
Modified: 2013-08-24 18:54 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample project (14.67 KB, application/zip)
2013-06-26 21:38 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2013-06-26 21:38:41 UTC
Created attachment 136363 [details]
Sample project

For some scenarios, the continuation should be nested. Take a look at the sample below (I had to extend the text area at Chrome to see it correctly):

final WebArchive war = ShrinkWrap
        .create(WebArchive.class, archiveName)
        .addPackages(
                true,
                //Arquillian
                ArquillianUtils.class.getPackage(),
                //Infra
                GenericsUtil.class.getPackage(),
                ApplicationContextHolder.class.getPackage(),
                ConnectionProvider.class.getPackage(), ResourcesFactory.class.getPackage(),
                //Abstracts
                AbstractEntity.class.getPackage(), AbstractService.class.getPackage(),
                EntityValidationException.class.getPackage(),
                //Testes com specs
                Specification.class.getPackage(), PessoaBasicSpec.class.getPackage())
        .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

After addPackages it is better to see the nested parameters intended as the sample shows, but NB just ignore it and shows as:

final WebArchive war = ShrinkWrap
        .create(WebArchive.class, archiveName)
        .addPackages(
        true,
        //Arquillian
        ArquillianUtils.class.getPackage(),
        //Infra
        GenericsUtil.class.getPackage(),
        ApplicationContextHolder.class.getPackage(),
        ConnectionProvider.class.getPackage(), ResourcesFactory.class.getPackage(),
        //Abstracts
        AbstractEntity.class.getPackage(), AbstractService.class.getPackage(),
        EntityValidationException.class.getPackage(),
        //Testes com specs
        Specification.class.getPackage(), PessoaBasicSpec.class.getPackage())
        .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

For me it is a wrong behaviour. This kind of indentation should be nested, even if we have more levels.

There is another behaviour that I think is wrong:

log.log(Level.WARNING, "[{0}] {1}.", new Object[]{cv.getPropertyPath().
    toString(), cv.getMessage()});

Why is it not considered a continuation and follow the size 8 I'd defined at the project configuration? It is using the indentation size instead continuation size, which is the correct behaviour here.

I am attaching a sample project with some sample files. You can see the class nb.Class at lines 14, 19 and 32 where I have added some comments about the issues in each line.
Comment 1 Dusan Balek 2013-06-27 12:49:30 UTC
Nested continuation indents have a couple of ugly corner cases. Consider the following line of code:

myInstance.methodFoo(arg1,arg2).methodBar(arg3);

It looks nice when newlines are placed in the following way:

myInstance
       .methodFoo(
               arg1,
               arg2
       )
       .methodBar(
               arg3
       );

However, the problem is the determine the correct (and nice looking) indentation in the following case:

myInstance.methodFoo(
arg1,
arg2
)
.methodBar(
arg3
);

One possible ugly solution:

myInstance.methodFoo(
        arg1,
        arg2
)
        .methodBar(
                arg3
        );

Another ugly solution:

myInstance.methodFoo(
                arg1,
                arg2
        )
        .methodBar(
                arg3
        );

What would you expect to be the correct indentation in this case?
Comment 2 Michel Graciano 2013-06-27 19:52:10 UTC
(In reply to comment #1)
Hi Dusan,
the expected behaviour IMHO is the second one, always following the continuation pattern. I have talked with coworkers and they agree about it too.
Comment 3 Dusan Balek 2013-08-23 11:28:33 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/36b9b2a2ef53
Comment 4 Michel Graciano 2013-08-24 18:54:45 UTC
Looks fine for me but as far as I can see, there is no option for it, right?

v. Build 20130824-7d0441ae75ed