| InternalCompletionContext.getExpectedTypesKeys returns add type keys [message #1076342] |
Wed, 31 July 2013 04:00  |
Eclipse User |
|
|
|
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 16:28   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04904 seconds