Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » What is the role of I*Binding in Eclipse JDT?
What is the role of I*Binding in Eclipse JDT? [message #1006156] Wed, 30 January 2013 09:30 Go to next message
Piotr Misztal is currently offline Piotr MisztalFriend
Messages: 1
Registered: January 2013
Junior Member
Hi all,

My current understanding is that JDT provides us two different interface and class hierachies for representing and manipulating Java code:

Java Model: provides a way of representing a java project. Fast to create but does not contain as many information as AST class hierachy, for example there are no information available about the exact position of each element in the source file (in AST that's available)

AST: more detailed representation of the source code plus provides means for manipulating it.

Is that correct?

Now, there is also a hierarchy of interfaces named I*Binding (starting at IBinding), for example IMethodBinding. So for example, we have 3 different types for dealing with methods:

IMethod (from Java Model) - http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/IMethod.html

MethodInvocation (from AST, could get it from IMethod) - http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/MethodInvocation.html

IMethodBinding - http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/IMethodBinding.html

From doc IMethodBinding seems very like MethodInvocation from AST but I don't see a clear distinction and when should I use them. Could someone please clarify this?

Cheers!
Re: What is the role of I*Binding in Eclipse JDT? [message #1006776 is a reply to message #1006156] Fri, 01 February 2013 18:54 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
To see the difference you may, e.g., look at the return type of a method:
- Java Model: String IMethod.getReturnType()
- AST: Type MethodDeclaration.getReturnType2()
- Binding: ITypeBinding IMethodBinding.getReturnType()

The first is just a String, the name of the return type. In the AST you get the same information but artfully wrapped in syntax nodes like SimpleType(SimpleName).

Only in the binding will you find the resolved type, an object which you can query for the various properties of this type. OTOH, resolving is an expensive operation, hence the other kinds, which can be constructed more easily.

HTH,
Stephan

Previous Topic:Eclipse Plugin Development - Editor
Next Topic:suppress null analysis for anonymous classes (using guava)
Goto Forum:
  


Current Time: Fri Apr 26 05:46:41 GMT 2024

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

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

Back to the top