[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] How to get AST for an IMethod (again)
|
- From: Simon Giesecke <simon.giesecke@xxxxxxx>
- Date: Sat, 17 May 2003 18:13:06 +0200
- Newsgroups: eclipse.tools
- Organization: University of Oldenburg
- User-agent: Pan/0.14.0 (I'm Being Nibbled to Death by Cats!)
Hi,
I know that the question has already been posted here, but I need some
clarification.
It is clear to me that I need to parse the method's compilation unit by
AST.parseCompilationUnit(method.getCompilationUnit())
Then, of course, I have the AST for the whole compilation unit, but how do
I easily find the subtree refering to my method?
At the moment I use an ASTVisitor to search the tree and compare the
IMethod.getSourceRange with MethodDeclaration.getStartPosition/getLength
First, this doesn't look very efficient to me, but what is more severe, it
doesn't work in at least one case: If there is a Non-JavaDoc-comment
preceding the method declaration, IMethod.getSourceRange contains the
comment and MethodDeclaration.getStartPosition/getLength does NOT.
If this is the only deviance between the two notions of source range, I
could of cause catch this case, but I have not found any specification of
what the ISourceRange of an ISourceReference implementor exactly is.
Kind regards,
Simon