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

Bug 481491

Summary: Completion of things on generic types introduces type parameters where they should be used
Product: [Eclipse Project] JDT Reporter: Jonas Wiklund <jwiklund>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description Jonas Wiklund CLA 2015-11-05 05:27:57 EST
When completing items (types or static methods) on a generic class that is not imported it eclipse incorrectly adds generic parameters (does not happen if the type is already imported).

Eg:

(if no import of java.util.Map exists)

Map.(Ctrl+Space Choose Map.Entry) -> Map<K,V>.Entry<K.V>

(if java.util.Map is imported)

Map.(Ctrl+Space Choose Map.Entry) -> Map.Entry<K,V>

This also happens for static methods

eg guavas ImmutableMap:

(if no import of com.google.common.collect.ImmutableMap)

ImmutableMap.(Ctrl+Space Choose of) -> ImmutableMap<K,V>.of()

(if com.google.common.collect.ImmutableMap is imported)

ImmutableMap.(Ctrl+Space Choose of) -> ImmutableMap.of()


A quick fix is to add

return ch != '<' && ch != '.';
instead of
return ch != '<';

at the end of shouldAppendArguments in LazyGenericTypeProposal. I think it never makes sense to include generic arguments before a dot in Java so it should be safe, but there is probably a more correct solution (not using the generic type as a requirement when you need to import the type for example).

On a related note, how do you build a plugin and use it in my normal eclipse installation? Using eclipse to export a eclipse plugin or building it with maven creates a plugin that is not recognized by eclipse (The manifest is somewhat different from the official one).
Comment 1 Eclipse Genie CLA 2020-05-11 12:35:08 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.