Bug 544831 - [content assist] Enum proposals for method parameters are not accurate
Summary: [content assist] Enum proposals for method parameters are not accurate
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.9   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 544829 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-02-26 11:04 EST by Simeon Andreev CLA
Modified: 2022-10-22 17:31 EDT (History)
2 users (show)

See Also:


Attachments
Screenshot showing the problem. Only 1 enum type is valid for the content assist, yet many more enum types are proposed. (302.55 KB, image/png)
2019-02-26 11:04 EST, Simeon Andreev CLA
no flags Details
Screenshot showing the problem. Only 1 enum type is valid for the content assist, yet many more enum types are proposed. (142.77 KB, image/png)
2019-02-26 11:07 EST, Simeon Andreev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2019-02-26 11:04:11 EST
Created attachment 277695 [details]
Screenshot showing the problem. Only 1 enum type is valid for the content assist, yet many more enum types are proposed.

Snippet is:

public class TestContentAssist {

	enum MyEnum {
		one,
		two
	}
	
	static void someMethod(MyEnum fruit) {
		System.out.println(fruit);
	}
	
	public static void main(String[] args) {
		someMethod(M);
	}

}

Invoke content assist after "M" at line "someMethod(M);", observe that any enum type with starting letter M is listed. This is too vague.
Comment 1 Simeon Andreev CLA 2019-02-26 11:07:12 EST
Created attachment 277697 [details]
Screenshot showing the problem. Only 1 enum type is valid for the content assist, yet many more enum types are proposed.
Comment 2 Andrey Loskutov CLA 2019-02-26 11:17:37 EST
*** Bug 544829 has been marked as a duplicate of this bug. ***
Comment 3 Stephan Herrmann CLA 2019-02-26 12:46:35 EST
If we think about type names in this position, everything should be legal, because we might complete any type to s.t. like "Util.getMyEnumFor(foo)".

OTOH, why show the enum type in the first place? Don't we want to directly propose all constants of the target enum?
Comment 4 Simeon Andreev CLA 2019-02-27 02:22:09 EST
(In reply to Stephan Herrmann from comment #3)
> If we think about type names in this position, everything should be legal,
> because we might complete any type to s.t. like "Util.getMyEnumFor(foo)".

Good point, though in 99% of the listed types would not be able to produce an enum. Maybe its possible to check whether the listed types can return the enum? If its not too expensive to check.

> OTOH, why show the enum type in the first place? Don't we want to directly
> propose all constants of the target enum?

Wouldn't that be more like a Java code template feature? Usually content assist only suggests the next "word".
Comment 5 Till Brychcy CLA 2019-02-27 02:45:04 EST
If you invoke completion after:

MyEnum x=

we directly suggest the enum constants followed by the MyEnum class.

It would be nice to have the same behaviour for method parameters, at least if the required target type can be determined unambiguously.

Anyway it really seems bogus to suggest unrelated Enum classes.
Comment 6 Eclipse Genie CLA 2022-10-22 17:31: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.

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.