eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
Smart autocomplete for types
As stated in this article about IDEA vs Eclipse, IDEA will only show autocomplete options based on context.
List<String> result= new ArrayList<>(5);
result.add(Integer. // ctrl-space
In this situation, it would wonderful if it only showed me the results that return strings. Instead, it shows me all of the constants at the top and I have to scroll to see anything that returns a string.
I doubt this would be very hard to implement because I assume it would just be a single if statement somewhere. It's possible I should be giving this issue directly to eclipse.jdt.core
so tell me if I should move.
If you try String s = Integer. //ctrl-space
you'll see methods returning String on top.
Eg. in VS Code :
So it seems to me the context is not aware of generics somehow. Please open a bug in jdt.core. Then we can ask @othomann to take a look ;-)
This is also probably meant for upstream (I'm not completely sure which responsibilities are handled by who) but would it be possible to autocomplete @Overrides?
what do you mean?
https://www.screencast.com/t/AYFxtppNr8 shows a more optimal workflow: type the name of the method you want to override, completion will add the @Override annotation and create the whole method body.
Unfortunately it is not that trivial to implement properly, as explained in #206, since we need to move some code around in upstream JDT
Doesn't work for me for some reason. Is it possible I have a conflicting package?
The override fix is not merged (see #206) because it's incomplete. It doesn't work for anyone at the moment.
Dears,
is there any update or something we could do to move this ticket forward?
this is really a very handy feature.
As stated in this article about IDEA vs Eclipse, IDEA will only show autocomplete options based on context.
List<String> result= new ArrayList<>(5); result.add(Integer. // ctrl-space
In this situation, it would wonderful if it only showed me the results that return strings. Instead, it shows me all of the constants at the top and I have to scroll to see anything that returns a string.
I doubt this would be very hard to implement because I assume it would just be a single if statement somewhere. It's possible I should be giving this issue directly to
eclipse.jdt.core
so tell me if I should move.
I think it's by design. Since the List#add() has two versions of signature:
-
boolean add(E e)
-
void add(int index, E element)
In this case, String
and int
are all expected types.
If you try result.get(Integer. // ctrl-space
, you can see int
and Integer
types comes first, and String
goes last.