Bug 575377 - [content assist] can't insert type proposal in lambda
Summary: [content assist] can't insert type proposal in lambda
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.20   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.21 M3   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks: 574913
  Show dependency tree
 
Reported: 2021-08-12 08:09 EDT by Julian Honnen CLA
Modified: 2021-08-15 07:53 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Honnen CLA 2021-08-12 08:09:24 EDT
Given the following code:

  void lambda(Object o) {
    Runnable r = () -> ((Str|))
  }

Content assist includes the correct proposals, but they can't be inserted (nothing happens).


After adding the variable, it works correctly:
    Runnable r = () -> ((Str|) o);


Tested in Version: 2021-09 (4.21)
Build id: I20210811-1800

It worked in 4.19
Comment 1 Stephan Herrmann CLA 2021-08-13 15:20:31 EDT
thanks, Julian,
I'm looking at this now.
Comment 2 Eclipse Genie CLA 2021-08-13 16:59:25 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/184002
Comment 3 Eclipse Genie CLA 2021-08-13 17:01:37 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/184003
Comment 4 Stephan Herrmann CLA 2021-08-13 17:04:55 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created:
> https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/184002

This fixes the problem, which was a matter of a bogus replacement range, viz. we were trying to replace "((Str" with "String", swallowing the two lparens. At this point the validate() method on the proposal answered false, because "((Str" is not a prefix of "String".

Solution is to avoid extending the source range of the assistNode when paren pairs are consumed.

(In reply to Eclipse Genie from comment #3)
> New Gerrit change created:
> https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/184003

A test in JDT/UI, fails without the fix.
Comment 7 Stephan Herrmann CLA 2021-08-15 07:53:04 EDT
(In reply to Eclipse Genie from comment #5)
> Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/184002 was
> merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=c0a65fcedd4a397c92f6d3942398d3a37f16b8ae

Fix released for 4.21 M3

(In reply to Eclipse Genie from comment #6)
> Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/184003 was
> merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=660c6a12cea3723fdbebfe16eaf7e573c05bc523

End-to-end test released, too.