What is the role of * Binding in Eclipse JDT?

My real understanding is that JDT provides us with two different interfaces and class hierarchies for representing and managing Java code:

  • Java model: provides a way to represent a java project. Quickly create, but do not contain as much information as the AST hierachy class, for example, there is no information about the exact position of each element in the source file (available in AST)

  • AST: A more detailed view of the source code plus provides a means to manipulate it.

Is it correct?

Now there is a hierarchy of interfaces called i * Binding (starting with IBinding ), for example IMethodBinding. So, for example, we have 3 different types for working with methods:

From doc, IMethodBinding seems very similar to MethodInvocation from AST, but I don’t see a clear difference even when to use it. Can someone clarify this?

+5
source share
1 answer

Raw AST nodes do not contain links between them, for example. from using a variable to declaring it, or from calling a method back to declaring a method. A MethodInvocation object can be checked for a method name, but you cannot immediately find out which method calls the class. this requires an analysis of the scope.

. IBinding AST, , . Declaration AST node MethodInvocation AST node CompilationUnit.findDeclaringNode(methodInvocationNode.resolveMethodBidning().getKey())

CompilationUnit.findDeclaringNode(method.getKey()), , AST node , IMethod.

MethodInvocation.resolveBinding().getKey() ==
MethodDeclaration.resolveBinding().getKey() ==
IMethod.getKey()
+8

All Articles