Bug 405113 - [1.8][content assist] lambda expression completions in contexts with a functional interface target type
Summary: [1.8][content assist] lambda expression completions in contexts with a functi...
Status: CLOSED DUPLICATE of bug 443091
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Gayan Perera CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 458319 (view as bug list)
Depends on: 443091
Blocks:
  Show dependency tree
 
Reported: 2013-04-07 16:35 EDT by ANIRBAN CHAKRABORTY CLA
Modified: 2021-11-19 15:02 EST (History)
15 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ANIRBAN CHAKRABORTY CLA 2013-04-07 16:35:00 EDT
public interface Foo { 
	boolean equals(Object obj); 
}

class X {
	void method1(){
		Foo f = <ctrl-space>
	}
}

Since the place assist is called, has a functional interface with void parameter, it it should suggest something like '() -> {}: lambda expression'. This is the same way as possible methods are suggested.
Comment 1 ANIRBAN CHAKRABORTY CLA 2013-04-07 16:43:52 EDT
Hello,

Mistakenly wrong example pasted. Please ignore the example in the description. Please consider the following example. The problem statement, otherwise remain the same.

public interface Foo { 
	int run(); 
}

class X {
	void method1(){
		Foo f = <ctrl-space>
	}
}

Thanks
Anirban
Comment 2 Srikanth Sankaran CLA 2013-12-01 00:31:58 EST
Why just a functional interface with a void parameter ? In fact it would be
more useful in non-void cases.

Markus, are you interested in supporting this feature ? If the target type in
the expression context is a functional interface type, then there could be
a quick assist. I primarily see this as UI side work, with perhaps core filling
in on the target type details.

Perhaps there could be a 
org.eclipse.jdt.core.CompletionContext.TL_FUNCTIONAL_TYPE_START and
this information could be augmented with org.eclipse.jdt.core.CompletionContext.getExpectedTypesSignatures() (/keys)

If you are interested, let us know the time frame.
Comment 3 Srikanth Sankaran CLA 2013-12-01 00:34:31 EST
As with everything else with Java8, there could be a number of complications
around overload resolution. We can consider every potential method as a candidate
and use argument positional information to compute the set of expected types.
Comment 4 Markus Keller CLA 2013-12-02 11:49:46 EST
Fixing bug summary. This is not for Quick Fix / Ctrl+1, but for Content Assist / Ctrl+Space.

We should already have anonymous class creation proposals in these places, so I'm not sure what additional infrastructure JDT Text (Dani) needs.
Comment 5 Markus Keller CLA 2014-07-26 13:36:51 EDT
This should also work in places where the expected type is defined by the context.

E.g. for method arguments. At |, I'd expect lambda proposals for FileFilter as well as for FilenameFilter:

	void foo(File folder) {
		for (File file : folder.listFiles(|)) {
			System.out.println(file);
		}
	}

The lambda proposals should show up without a prefix and maybe also with a "->" as prefix. The latter would be necessary in case the lambda proposals don't get the highest relevance.

The additional info for the lambda proposals should show the Javadoc of the functional interface method.
Comment 6 Noopur Gupta CLA 2014-08-26 10:51:06 EDT
(In reply to Markus Keller from comment #4)
> We should already have anonymous class creation proposals in these places,
> so I'm not sure what additional infrastructure JDT Text (Dani) needs.

If I just press Ctrl+space at the locations specified in examples of comment #1 and comment #5, I do not get the proposals for creating anonymous inner types.
I get those only when there is "new " as prefix while pressing Ctrl+space.

However, for lambda creations, content assist should work without any prefix or with "->" as prefix as mentioned in comment #5.
Comment 7 Noopur Gupta CLA 2015-01-28 04:24:14 EST
*** Bug 458319 has been marked as a duplicate of this bug. ***
Comment 8 Noopur Gupta CLA 2015-01-28 04:26:59 EST
Bug 443091 has been reported for support from JDT/Core.
Comment 9 Serhiy CLA 2015-04-22 03:46:03 EDT
Any updates?
Comment 10 Serhiy CLA 2015-09-14 07:11:01 EDT
Is this planned for the 2016 release?
Comment 11 Dani Megert CLA 2016-04-05 05:06:36 EDT
(In reply to Serhiy from comment #10)
> Is this planned for the 2016 release?

No.
Comment 12 Serhiy CLA 2016-04-06 08:55:31 EDT
(In reply to Dani Megert from comment #11)
> (In reply to Serhiy from comment #10)
> > Is this planned for the 2016 release?
> 
> No.

Sad. I realize that development team is very limited but still it is very sad to not have this for so many years. Can you provide any entry point (docs and examples) how a person not familiar with Eclipse JDT development can try to start working on this issue?
Comment 13 Serhiy CLA 2016-06-30 02:51:47 EDT
Just wanted to add that few days ago I have tried daily build of NetBeans and they have this feature implemented. Works nicely in NetBeans (event better than this feature is implemented in IDEA). So I would say that from my personal point of view daily build of NetBeans can be used as a good example of how such feature needs to work.

So really hope it will get into 4.7.

Thanks,
Serhiy
Comment 14 Serhiy CLA 2016-10-10 04:52:23 EDT
Any updates?
Comment 15 Mauro Molinari CLA 2017-11-10 06:25:23 EST
This would be EXTREMELY useful. I also created bug 527104 (could not find this), because other contexts completions/code templates would be useful (for Optionals, for instance).
Comment 16 Noopur Gupta CLA 2018-04-13 06:25:02 EDT
(In reply to Noopur Gupta from comment #8)
> Bug 443091 has been reported for support from JDT/Core.
Removing the target milestone. It can be re-assigned when the core support is available.
Comment 17 Lars Vogel CLA 2021-02-11 04:30:51 EST
Gayan, can you have a look?
Comment 18 Gayan Perera CLA 2021-02-11 04:33:03 EST
Sure i can add it in 4.20 release
Comment 19 Lars Vogel CLA 2021-11-19 07:11:37 EST
Gayan, can this bug be marked as fixed?
Comment 20 Gayan Perera CLA 2021-11-19 14:39:08 EST
Yes i think this is also covered in https://bugs.eclipse.org/bugs/show_bug.cgi?id=443091
Comment 21 Lars Vogel CLA 2021-11-19 15:02:47 EST

*** This bug has been marked as a duplicate of bug 443091 ***