How to get the type of the class being analyzed? [message #115802] |
Wed, 17 October 2007 14:21 |
Eclipse User |
|
|
|
Originally posted by: saorf.de.ibm.com
I start with this:
CodeReviewResource resource =
(CodeReviewResource)getProvider().getProperty(history.getHis toryId(),
CodeReviewProvider.RESOURCE_PROPERTY);
List typeDeclarations =
resource.getTypedNodeList(resource.getResourceCompUnit(),
ASTNode.TYPE_DECLARATION);
How can I get the type, the whole tree represents? If I say
typeDeclarations.get(0).getClass(), I get the type TypeDeclaration.
That makes sence.
But how can I get the type of the class I analyze (Is there a special
expression describing this type?)?
|
|
|
Re: How to get the type of the class being analyzed? [message #115909 is a reply to message #115802] |
Thu, 18 October 2007 09:07 |
Eclipse User |
|
|
|
Originally posted by: s_gutz.ca.ibm.com
Once you get the type declaration you can resolve it to a binding.
TypeBinding binding = td.resolveTypeBinding();
Note that you should always check the returned value for null before
using it and fail gracefully. Do this because it is possible that the
code you are analyzing doesn't actually compile.
Steve
Sascha Orf wrote:
> I start with this:
>
> CodeReviewResource resource =
> (CodeReviewResource)getProvider().getProperty(history.getHis toryId(),
> CodeReviewProvider.RESOURCE_PROPERTY);
>
> List typeDeclarations =
> resource.getTypedNodeList(resource.getResourceCompUnit(),
> ASTNode.TYPE_DECLARATION);
>
> How can I get the type, the whole tree represents? If I say
> typeDeclarations.get(0).getClass(), I get the type TypeDeclaration.
>
> That makes sence.
>
> But how can I get the type of the class I analyze (Is there a special
> expression describing this type?)?
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03179 seconds