Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 15:07 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 8
Registered: June 2011
Junior Member
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 15:08]

Report message to a moderator

Re: Access to source code of method (getBody()) from IMethodBinding [message #699270 is a reply to message #698969] Thu, 21 July 2011 08:49 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
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 11:55 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 8
Registered: June 2011
Junior Member
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 11:56]

Report message to a moderator

Re: Access to source code of method (getBody()) from IMethodBinding [message #703044 is a reply to message #702460] Wed, 27 July 2011 05:05 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Yes, that should do.
Previous Topic:Help! LDAP issue and debugger hang
Next Topic:JDT and binding
Goto Forum:
  


Current Time: Fri Apr 26 16:58:23 GMT 2024

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

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

Back to the top