Bug 458329

Summary: [1.8][quick assist] Allow for converting an anonymous class into a method reference, if possible
Product: [Eclipse Project] JDT Reporter: Lukas Eder <lukas.eder>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: Lars.Vogel, noopur_gupta
Version: 4.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 449106    
Attachments:
Description Flags
screenshot.png none

Description Lukas Eder CLA 2015-01-24 07:18:34 EST
Some anonymous classes can be represented by method references, e.g. as in this example:

--------------------------------------------------------
import java.util.function.Consumer;

public class Test {

    public static void main(String[] args) {
        run(new Consumer<Object>() {
            @Override
            public void accept(Object o) {
                System.out.println(o);
            }
        });
    }

    static void run(Consumer<Object> r) {
        r.accept("Hello");
    }
}
--------------------------------------------------------

The following code is equivalent:

--------------------------------------------------------
    public static void main(String[] args) {
        run(System.out::println);
    }
--------------------------------------------------------

Today, I can convert the anonymous class into a lambda, and then into a method reference. It would be nice to have an option in content assist to go directly from anonymous class to method reference.
Comment 1 Noopur Gupta CLA 2015-01-28 04:37:44 EST
(In reply to Lukas Eder from comment #0)
> Today, I can convert the anonymous class into a lambda, and then into a
> method reference. It would be nice to have an option in content assist to go
> directly from anonymous class to method reference.
You mean:
in *content assist* => in *quick assist*
Comment 2 Lukas Eder CLA 2015-01-28 04:56:21 EST
> You mean:
> in *content assist* => in *quick assist*

Yes, I'm sorry for the confusion. I mean in *quick assist*, i.e. when hitting Ctrl+1
Comment 3 Lars Vogel CLA 2020-05-18 08:04:54 EDT
I think this one is fixed? Lukas, can you check?
Comment 4 Lukas Eder CLA 2020-05-18 09:18:32 EDT
Not fixed in Version 2020-03 / Build id 20200313-1211 yet, see screenshot
Comment 5 Lukas Eder CLA 2020-05-18 09:19:10 EDT
Created attachment 282909 [details]
screenshot.png