InternalCompletionContext.getExpectedTypesKeys returns add type keys [message #1076342] |
Wed, 31 July 2013 08:00 |
|
Hi JDT,
we stumbled over a completion scenario which we can't make sense of. Maybe one of you guys can help us out here?
The code in which completion is triggered is as follows:
import java.util.*;
public class TestClass1 {
public void __test() throws Exception {
java.util.Arrays.asList(get$)
}
}
For this particular completion location (->$), InternalCompletionContext.getExpectedTypesKeys returns "[Ljava/util/Arrays;.asList<T:Ljava/lang/Object;>([TT;)Ljava/util/List<TT;>;:TT;" which looks a bit broken to me.
Shouldn't it just return Ljava/util/List<T> or something along these lines?
Best,
Marcel
(We are working on Eclipse Kepler SR0)
|
|
|
Re: InternalCompletionContext.getExpectedTypesKeys returns add type keys [message #1077506 is a reply to message #1076342] |
Thu, 01 August 2013 20:28 |
Stephan Herrmann Messages: 1853 Registered: July 2009 |
Senior Member |
|
|
Hi Marcel,
Marcel Bruch wrote on Wed, 31 July 2013 10:00
InternalCompletionContext.getExpectedTypesKeys returns "[Ljava/util/Arrays;.asList<T:Ljava/lang/Object;>([TT;)Ljava/util/List<TT;>;:TT;" which looks a bit broken to me.
Yeah, that makes for some tricky parsing.
If this is to express the expected type for a parameter for asList() then we'd either expect T[] or T, right?
But then, T isn't really a type in Java, so we have to be more specific.
In a binary signature a type variable T would be encoded as "[TT;", but I guess the signature also has to include the element which declares T.
As we recognize "[" and "TT;" as head and tail of the string, we are left with this
Ljava/util/Arrays;.asList<T:Ljava/lang/Object;>([TT;)Ljava/util/List<TT;>;
Decoded into source language:
List<T> Arrays.asList<T extends Object>(T)
Yep, that's the element which declares "T".
Makes more sense now?
As you certainly don't want to do this parsing yourself, org.eclipse.jdt.core.Signature will be your friend, but you probably know that.
cheers,
Stephan
|
|
|
|
|
Re: InternalCompletionContext.getExpectedTypesKeys returns add type keys [message #1077537 is a reply to message #1077531] |
Thu, 01 August 2013 21:16 |
|
Thanks again. Last question on this:
I would like to know that the expected type is an Array of Object to make reasonable recommendations. I just tried a couple of things on Signature but could not find a good result to resolve the type to something meaningful except [TT; - and apparently this signature thingish thing this goes a bit beyond my knowledge. Can scribble a way how I can resolve this in a secure way to a "normal" non-parameterized type?
This would certainly get you in the right position for a beer at EclipseCon
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03557 seconds