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 255280 - Issue formatting lambda expressions in some specific scenarios
Summary: Issue formatting lambda expressions in some specific scenarios
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-14 17:41 UTC by Michel Graciano
Modified: 2016-04-27 13:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample project (14.61 KB, application/zip)
2015-09-14 17:53 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2015-09-14 17:41:36 UTC
In some scenarios the lambda expressions formatting is not ideal, as follow.

Original source:
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.BiPredicate;

public class NewClass {

    public static void main(String[] args) {
        // Working scenario
        new ArrayList<>().stream()
                .filter(o -> true)
                .forEach(o ->
                        System.out.println(""));

        // Not working scenario
        merge(new ArrayList<Object>(),
                (obj, collection) -> collection
                .stream()
                .anyMatch(o -> false));
    }

    public static <T> Object merge(final Collection<T> objs,
            final BiPredicate<T, Collection<Object>> isNew) {
        return null;
    }

}

As we can see at line 12, the 'System.out.println(""));' is correctly indented. But it is not the same at line 17 and 18. My expected behaviour is:

// Not working scenario
merge(new ArrayList<Object>(),
        (obj, collection) -> collection
                .stream()
                .anyMatch(o -> false));

or even:

// Not working scenario
merge(new ArrayList<Object>(),
        (obj, collection) ->
                collection
                        .stream()
                        .anyMatch(o -> false));
Comment 1 Michel Graciano 2015-09-14 17:45:16 UTC
Product Version: NetBeans IDE Dev (Build 20150909-6ff4934e5978)
Updates: Updates available
Java: 1.8.0_51; Java HotSpot(TM) 64-Bit Server VM 25.51-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_51-b16
System: Linux version 3.4.63-2.44-desktop running on amd64; UTF-8; en_US (nb)
Comment 2 Michel Graciano 2015-09-14 17:53:47 UTC
Created attachment 156163 [details]
Sample project

I am attaching a project with all the customizations we have in our project due formatting. It may be a issue with some specific property.
Comment 3 Svata Dedic 2016-04-27 13:14:15 UTC
Seems that lambda "->" does not increase the base ident