Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » lambda expression template
lambda expression template [message #1350769] Mon, 12 May 2014 20:28 Go to next message
Francois Guillot is currently offline Francois GuillotFriend
Messages: 6
Registered: February 2012
Junior Member

I wanted to check Java 8 integration with Eclipse Luna so I downloaded the M7 Luna from

After configuring the JDK to jdk8u5, I started some tests.

Let's say you have a nice Runnable like

Runnable r = new Runnable() {
    public void run() {

If you select the

new Runnable() {
  public void run() {

block and press Ctrl-1 (Quick Fix), you get the suggestion to change it to a lambda, resulting in
Runnable r = () -> System.out.println("foo");
, which is pretty cool.

But a nicer thing whould be to actually help creating lambda expression. For instance, if you type
Runnable r = |
(with | being the cursor location) and press ctrl+Space (content-assist), I would have expected to find a "create a lambda expression from this functional interface" option in the displayed popup. But nothing new is available.

Do you know if this will be implemented in the future ? I think it might have something to do with the templates (Java/Editor/Templates in preferences) but I actually never experimented with them.
Re: lambda expression template [message #1353423 is a reply to message #1350769] Tue, 13 May 2014 22:45 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
One problem with the proposed quick fix is: which style of lambda should be proposed?
- explicit arguments or arguments with elided types?
- expression body or block body?
Combines to 4 styles that need to be shown for you to select from.

Compare this to the net value of saved keystrokes:
Runnable r = 

Runnable r = () -> 

You may still file an RFE, but I personally wouldn't give it high priority.

Re: lambda expression template [message #1366685 is a reply to message #1353423] Mon, 19 May 2014 12:26 Go to previous message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 58
Registered: December 2012

[Updated on: Mon, 19 May 2014 12:27]

Report message to a moderator

Previous Topic:How to use toggle comment API in JDT
Next Topic:How to setup JDT UI development environment
Goto Forum:

Current Time: Sat May 25 14:32:06 GMT 2024

Powered by FUDForum. Page generated in 0.03678 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top