Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 492405

Summary: adding a lambda as a method argument inserts mismatched parentheses
Product: [Eclipse Project] JDT Reporter: Colin Sharples <ctg>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: noopur_gupta
Version: 4.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Colin Sharples CLA 2016-04-25 17:30:24 EDT
If you use content assist to fill out a method call that takes a functional interface as a parameter, and attempt to insert a Lambda expression that itself has multiple arguments, content assist inserts the wrong number of parentheses.

Steps to reproduce:

1. Create an object that has a method with a functional interface as parameter, where the interface method has multiple parameters. An example is the JavaFX properties that you can add a ChangeListener.

  TextField text = new TextField();
  text.textProperty().

2. Use ctrl+space to select the addListener(ChangeListener) method
  text.textProperty().addListener(listener); 
 
  the listener argument is highlighted and can be over-typed.

3. The ChangeListener changed() method takes three parameters which are generally called something like "ov", "oldValue" and "newValue", so type the following to replace the placeholder text:
  
  (ov, oldValue, newValue)

Expected result: cursor position shown by |
  text.textProperty().addListener((ov, oldValue, newValue)|); 

Actual result:
  text.textProperty().addListener((ov, oldValue, newValue);|

so you end up with a missing parenthesis and the cursor in the wrong place.
Comment 1 Noopur Gupta CLA 2016-05-05 05:57:48 EDT
Similar to bug 477615.

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