[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[jdt-apt-dev] About TypeDeclaration.getActualTypeArguments()
|
- From: Compl Yue Still <complystill@xxxxxxxxxxxx>
- Date: Sat, 10 Dec 2005 00:38:03 -0800 (PST)
- Delivered-to: jdt-apt-dev@eclipse.org
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.cn; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=fzp7BGnlGn7zFzykcPHjRfqujtJoPP/TwhJPwbxUKXY5TQWsyuUiAi4MWoR/8nhSTFQtGA9G1TZBmzvFTQk6Q+M5rh7KlktSdjTGRyyqsHBcPCe/JIK3HfdbJdoMq7Uy7iGKYnBpJg1BHMLxupxMaJmnMHnyZxWUtPjKHI3w9/8= ;
Hello buddies,
I met some problem with TypeDeclaration.getActualTypeArguments(), I don't know if my understand
is correct that this invocation should return the concrete types substituting the formal type
parameters as possible.
The last straw was that I called Types.isAssignable(TypeMirror, TypeMirror) with a type
parameter from the generic type of a field declaration, and ended up with a
ClassCastException:org.eclipse.jdt.apt.core.internal.declaration.TypeParameterDeclarationImpl
After some dig, I found the implementation here:
public Collection<TypeMirror> getActualTypeArguments()
{
final ITypeBinding type = getTypeBinding();
final ITypeBinding[] typeArgs = type.getTypeArguments();
if( typeArgs == null || typeArgs.length == 0 )
return Collections.emptyList();
final Collection<TypeMirror> result = new ArrayList<TypeMirror>(typeArgs.length);
for( ITypeBinding arg : typeArgs ){
final TypeMirror mirror = Factory.createTypeMirror(arg, _env);
if(arg == null)
result.add(Factory.createErrorClassType(arg));
else
result.add(mirror);
}
return result;
}
Is this CORRECT? If it is, please any buddy tell me how to test that whether the type parameter
of a field declaration is sub class of a specific one? Say, when processing annotations, how can I
see whether a field is of type Set<? extends Collection>, but not a Set<String> ? In this case a
field of type Set<List> should return true while type Set<String> should return false.
Thanks in advance to any hint!
Compl Yue Still
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com