Bug 483515 - [1.8][content assist] after single colon ":" for method reference => shows wrong proposals
Summary: [1.8][content assist] after single colon ":" for method reference => shows wr...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 483517
  Show dependency tree
 
Reported: 2015-12-02 14:40 EST by Markus Keller CLA
Modified: 2020-04-16 03:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2015-12-02 14:40:23 EST
I20151201-1100

Content Assist after a single colon ":" for an incomplete method reference shows wrong proposals.

Example:

class MyException extends RuntimeException {
    void foo() {
        Supplier<String> s = String:
    }
    void bar(Supplier<String> s) {
        bar(String:);
    }
    void baz(Supplier<String> s) {
        s = String:
    }
}

After the : , I get proposals as if this was the beginning of a new statement. I would expect either no proposals at all, or even better: the same proposals as when I replace "String:" by "String::".

If the problem is that's not trivial to distinguish this case from a labeled statement, then a heuristic could be that token sequences
  "=" <type> ":"
or
  "(" <type> ":"
are always the start of a method reference expression and never a labeled statement.
Comment 1 Markus Keller CLA 2016-01-08 16:03:24 EST
(In reply to Markus Keller from comment #0)
I don't know how much of an AST context is available to content assist, but here's a case where the colon is not the delimiter for a labeled statement, but part of a conditional expression:

    void foo(int a, boolean b){
        int aa;
        int c = b ? aa = a :/*|*/ 0;
    }

Syntactically, this matches the heuristic proposed in comment 0. The 'a' could even be a type reference, and the ':' just the first colon for a method reference! These cases cannot be distinguished if you consider everything after the caret as incomplete (which I think is a basic assumption of content assist).

I don't see a good solution any more that would be correct in all cases.
Comment 2 Eclipse Genie CLA 2018-04-23 17:17:03 EDT
New Gerrit change created: https://git.eclipse.org/r/121607
Comment 3 Kenneth Styrberg CLA 2018-04-23 17:20:02 EDT
Hmm, the fix is for Java only and is not suitable to be in jface.text plugin. I Abandoned it in Gerrit
Comment 4 Eclipse Genie CLA 2020-04-16 03:20:25 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.