Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Access to source code of method (getBody()) from IMethodBinding
Access to source code of method (getBody()) from IMethodBinding [message #698969] Wed, 20 July 2011 11:07 Go to next message
Eclipse UserFriend
Hi People,

I'm working on source code analysis and ASTVisitor for Java code.

From MethodInvocation node, i'm doing as follow :

public boolean visit(MethodInvocation mi) {
   IMethodBinding mb = mi.resolveMethodBinding();
   ...
}


and i'm thus able to get informations of the called method.

Now, i'd like to access the declaration of the method, its source code, its body, similar to the method "getBody()" from "MethodDeclartion" class.

And i don't find any way to perform that.

Any idea?

Thanks.
Regards,

Cédric

[Updated on: Wed, 20 July 2011 11:08] by Moderator

Re: Access to source code of method (getBody()) from IMethodBinding [message #699270 is a reply to message #698969] Thu, 21 July 2011 04:49 Go to previous messageGo to next message
Eclipse UserFriend
If you have the CompilationUnit of the declaration you could call findDeclarationNode() to get the MethodDeclaration.
Alternatively you could call createASTs() passing the binding key.
Re: Access to source code of method (getBody()) from IMethodBinding [message #702460 is a reply to message #699270] Tue, 26 July 2011 07:55 Go to previous messageGo to next message
Eclipse UserFriend
You mean, i could be able to do so :
parser.createASTs(new String[] {},null,new String[] {mb.getKey()},req,null);

?

[Updated on: Tue, 26 July 2011 07:56] by Moderator

Re: Access to source code of method (getBody()) from IMethodBinding [message #703044 is a reply to message #702460] Wed, 27 July 2011 01:05 Go to previous message
Eclipse UserFriend
Yes, that should do.
Previous Topic:Help! LDAP issue and debugger hang
Next Topic:JDT and binding
Goto Forum:
  


Current Time: Mon Jul 14 19:26:32 EDT 2025

Powered by FUDForum. Page generated in 0.04474 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top