Bug 428824 - [1.8][assist] Method/constructor reference completion proposal should not ignore target type
Summary: [1.8][assist] Method/constructor reference completion proposal should not ign...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Manoj N Palat CLA
URL:
Whiteboard: stalebug
Keywords:
: 443710 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-02-22 12:10 EST by Srikanth Sankaran CLA
Modified: 2023-05-13 05:22 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2014-02-22 12:10:00 EST
This is a follow up of https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081.
In that CR, I have actually added basic support for code completion at reference
expressions past the ::

We basically offer any and all methods that match the prefix, completely ignoring
the target type. We should use the target type to weed out methods that won't
be applicable.
Comment 1 Srikanth Sankaran CLA 2014-09-10 11:09:29 EDT
*** Bug 443710 has been marked as a duplicate of this bug. ***
Comment 2 Manoj N Palat CLA 2015-04-07 23:55:56 EDT
Moving Out of 4.5
Comment 3 Markus Keller CLA 2015-12-03 06:22:36 EST
The exact target type is often unknown in incomplete code, so we cannot be perfect here.

But at least the method reference content assist proposals with a structurally matching signature type should be more relevant than the other proposals.

Example:

    new Random(0).ints(f, 'a', 'z' + 1).collect(StringBuilder::new, null, null);

The API IntStream#collect(Supplier<R>, ObjIntConsumer<R>, BiConsumer<R, R>) tells that the first parameter requires a method reference for a static method or constructor that takes no argument and that returns an R. I.e. after "StringBuilder::", the only structurally applicable proposal is the "new" keyword. This should be on first place.

The second parameter of collect(.., ObjIntConsumer<R>, ..) requires a method ref that matches one of these signatures:
(a) instance method * *(int)
(b) static method   * *(R, int)

We don't know the R, and the int may also match Integer or Object or even Object..., but even without knowing the exact signature, we can:
- rule out methods like capacity(), delete(int, int), etc.
- prefer append(int) over append(boolean) and the like
Comment 4 Stephan Herrmann CLA 2017-05-25 11:50:19 EDT
If completing the last missing piece in an expression-to-be-type-inferred, then we _could_ perform type inference for each potential proposal, to filter/rank low those that would yield type errors.
Comment 5 Manoj N Palat CLA 2018-05-16 01:06:42 EDT
bulk move out of 4.8
Comment 6 Eclipse Genie CLA 2020-08-30 01:42:46 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Stephan Herrmann CLA 2021-05-22 17:51:02 EDT
At least the example from comment 3 could be fixable with recent improvements in this area.
Comment 8 Eclipse Genie CLA 2023-05-13 05:22:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.