Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make code completion for Java 8 lambda parameters in Eclipse work?

Suppose I have an interface like this:

@FunctionalInterface
public interface ModifierFunction {

    Game applyModifier(Game game, Card card, Modifier modifier);
}

and some class where I use it:

SHOWDOWN_BUFF((game, card, modifier) -> {
    game. // <- I get no proposals from Eclipse here
    return game;
})

My problem is that if I press Ctrl+Space I can't see Game's methods...in fact I get no proposals at all. It does not work if I use this syntax either:

SHOWDOWN_BUFF((Game game, Card card, Modifier modifier) -> {
    game. // <- I get no proposals from Eclipse here either
    return game;
})

How can I get code completion to work in Eclipse Luna for Java 8?

edit: I'm using Version: Luna Service Release 1 (4.4.1)

like image 343
Adam Arold Avatar asked Jan 21 '15 16:01

Adam Arold


People also ask

How do you pass a lambda function as a parameter in Java?

Passing Lambda Expressions as ArgumentsIf you pass an integer as an argument to a function, you must have an int or Integer parameter. If you are passing an instance of a class as a parameter, you must specify the class name or the object class as a parameter to hold the object.

Which is correct about Java 8 lambda expression?

Q 5 - Which of the following is correct about Java 8 lambda expression? A - Lambda expressions are used primarily to define inline implementation of a functional interface.

Is Java 8 lambda use parameter type inference?

Type Inference means that the data type of any expression (e.g. method return type or parameter type) can be deduced automatically by the compiler. Groovy language is a good example of programming languages supporting Type Inference. Similarly, Java 8 Lambda expressions also support Type inference.

What is lambda expression in Java 8 with example?

Lambda Expressions were added in Java 8. A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.


1 Answers

Parameter completion within Java 8 Lambda expression works with Eclipse Mars (4.5.0). https://www.eclipse.org/eclipse/news/4.5/jdt.php

like image 64
Ronan Fauglas Avatar answered Oct 15 '22 18:10

Ronan Fauglas