Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
  
  
  package org.eclipse.jdt.core.dom;
  
A binding resolver is an internal mechanism for figuring out the binding for a major declaration, type, or name reference. This also handles the creation and mapping between annotations and the ast nodes that define them.

The default implementation serves as the default binding resolver that does no resolving whatsoever. Internal subclasses do all the real work.

  
  class BindingResolver {

Creates a binding resolver.
  
  		// default implementation: do nothing
  	}

Finds the corresponding AST node from which the given binding originated. Returns null if the binding does not correspond to any node in the compilation unit.

The following table indicates the expected node type for the various different kinds of bindings:

  • package - a PackageDeclaration
  • class or interface - a TypeDeclaration or a ClassInstanceCreation (for anonymous classes)
  • primitive type - none
  • array type - none
  • field - a VariableDeclarationFragment in a FieldDeclaration
  • local variable - a SingleVariableDeclaration, or a VariableDeclarationFragment in a VariableDeclarationStatement or VariableDeclarationExpression
  • method - a MethodDeclaration
  • constructor - a MethodDeclaration
  • annotation type - an AnnotationTypeDeclaration
  • annotation type member - an AnnotationTypeMemberDeclaration

The implementation of CompilationUnit.findDeclaringNode forwards to this method.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
binding the binding
Returns:
the corresponding node where the bindings is declared, or null if none
  
  		return null;
  	}

Finds the corresponding AST node from which the given binding key originated. The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
bindingKey the binding key
Returns:
the corresponding node where the bindings is declared, or null if none
  
  	ASTNode findDeclaringNode(String bindingKey) {
  		return null;
  	}

Finds the corresponding AST node from which the given annotation instance originated. The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
instance the dom annotation
Returns:
the corresponding node where the bindings is declared, or null if none
 
 		return null;
 	}

Allows the user to get information about the given old/new pair of AST nodes.

The default implementation of this method does nothing. Subclasses may reimplement.

Parameters:
currentNode the new node
Returns:
org.eclipse.jdt.internal.compiler.ast.ASTNode
 
 		return null;
 	}

Returns the new method binding corresponding to the given old method binding.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
methodBinding the old method binding
Returns:
the new method binding
 
 		return null;
 	}

Returns the new member value pair binding corresponding to the given old value pair binding.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
valuePair the old value pair binding
Returns:
the new member value pair binding
 
 		return null;
 	}

Returns the new package binding corresponding to the given old package binding.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
packageBinding the old package binding
Returns:
the new package binding
 
 		return null;
 	}

Returns the new type binding corresponding to the given old type binding.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
referenceBinding the old type binding
Returns:
the new type binding
 
 		return null;
 	}


Returns the new type binding corresponding to the given variableDeclaration. This is used for recovered binding only.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
variableDeclaration the given variable declaration
Returns:
the new type binding
 
 		return null;
 	}

Returns the new type binding corresponding to the given type. This is used for recovered binding only.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the given type
Returns:
the new type binding
 
 		return null;
 	}

Returns the new type binding corresponding to the given recovered type binding.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
recoveredTypeBinding the recovered type binding
dimensions the dimensions to add the to given type binding dimensions
Returns:
the new type binding
 
 	ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBindingint dimensions) {
 		return null;
 	}

Returns the new variable binding corresponding to the given old variable binding.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
binding the old variable binding
Returns:
the new variable binding
 
 		return null;
 	}

Return the working copy owner for the receiver.

The default implementation of this method returns null. Subclasses may reimplement.

Returns:
the working copy owner for the receiver
 
 		return null;
 	}

Return the new annotation corresponding to the given old annotation

The default implementation of this method returns null Subclasses may reimplement.

Parameters:
instance the old annotation
Returns:
the new DOM annotation
 
 		return null;
 	}
 
 		return false;
 	}
 
 		return false;
 	}
 
 		return false;
 	}

Returns the compiler lookup environment used by this binding resolver. Returns null if none.

Returns:
the lookup environment used by this resolver, or null if none.
 
 		return null;
 	}

This method is used to record the scope and its corresponding node.

The default implementation of this method does nothing. Subclasses may reimplement.

Parameters:
astNode
 
 	void recordScope(ASTNode astNodeBlockScope blockScope) {
 		// default implementation: do nothing
 	}

Returns whether this expression node is the site of a boxing conversion (JLS3 5.1.7). This information is available only when bindings are requested when the AST is being built.

Returns:
true if this expression is the site of a boxing conversion, or false if either no boxing conversion is involved or if bindings were not requested when the AST was created
Since:
3.1
 
 	boolean resolveBoxing(Expression expression) {
 		return false;
 	}

Returns whether this expression node is the site of an unboxing conversion (JLS3 5.1.8). This information is available only when bindings are requested when the AST is being built.

Returns:
true if this expression is the site of an unboxing conversion, or false if either no unboxing conversion is involved or if bindings were not requested when the AST was created
Since:
3.1
 
 	boolean resolveUnboxing(Expression expression) {
 		return false;
 	}

Resolves and returns the compile-time constant expression value as specified in JLS2 15.28, if this expression has one. Constant expression values are unavailable unless bindings are requested when the AST is being built. If the type of the value is a primitive type, the result is the boxed equivalent (i.e., int returned as an Integer); if the type of the value is String, the result is the string itself. If the expression does not have a compile-time constant expression value, the result is null.

Resolving constant expressions takes into account the value of simple and qualified names that refer to constant variables (JLS2 4.12.4).

Note 1: enum constants are not considered constant expressions either. The result is always null for these.

Note 2: Compile-time constant expressions cannot denote null. So technically NullLiteral nodes are not constant expressions. The result is null for these nonetheless.

Returns:
the constant expression value, or null if this expression has no constant expression value or if bindings were not requested when the AST was created
Since:
3.1
 
 		return null;
 	}

Resolves and returns the binding for the constructor being invoked.

The implementation of ClassInstanceCreation.resolveConstructor forwards to this method. Which constructor is invoked is often a function of the context in which the expression node is embedded as well as the expression subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
expression the expression of interest
Returns:
the binding for the constructor being invoked, or null if no binding is available
 
 		return null;
 	}

Resolves and returns the binding for the constructor being invoked.

The implementation of ConstructorInvocation.resolveConstructor forwards to this method. Which constructor is invoked is often a function of the context in which the expression node is embedded as well as the expression subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
expression the expression of interest
Returns:
the binding for the constructor being invoked, or null if no binding is available
 
 		return null;
 	}
Resolves and returns the binding for the constructor being invoked.

The implementation of ConstructorInvocation.resolveConstructor forwards to this method. Which constructor is invoked is often a function of the context in which the expression node is embedded as well as the expression subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
enumConstantDeclaration the enum constant declaration of interest
Returns:
the binding for the constructor being invoked, or null if no binding is available
 
 		return null;
 	}
Resolves and returns the binding for the constructor being invoked.

The implementation of SuperConstructorInvocation.resolveConstructor forwards to this method. Which constructor is invoked is often a function of the context in which the expression node is embedded as well as the expression subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
expression the expression of interest
Returns:
the binding for the constructor being invoked, or null if no binding is available
 
 		return null;
 	}
Resolves the type of the given expression and returns the type binding for it.

The implementation of Expression.resolveTypeBinding forwards to this method. The result is often a function of the context in which the expression node is embedded as well as the expression subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
expression the expression whose type is of interest
Returns:
the binding for the type of the given expression, or null if no binding is available
 
 		return null;
 	}

Resolves the given field access and returns the binding for it.

The implementation of FieldAccess.resolveFieldBinding forwards to this method. How the field resolves is often a function of the context in which the field access node is embedded as well as the field access subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
fieldAccess the field access of interest
Returns:
the binding for the given field access, or null if no binding is available
 
 		return null;
 	}

Resolves the given super field access and returns the binding for it.

The implementation of SuperFieldAccess.resolveFieldBinding forwards to this method. How the field resolves is often a function of the context in which the super field access node is embedded as well as the super field access subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
fieldAccess the super field access of interest
Returns:
the binding for the given field access, or null if no binding is available
 
 		return null;
 	}

Resolves the given import declaration and returns the binding for it.

The implementation of ImportDeclaration.resolveBinding forwards to this method.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
importDeclaration the import declaration of interest
Returns:
the binding for the given package declaration, or the package binding (for on-demand imports) or type binding (for single-type imports), or null if no binding is available
 
 	IBinding resolveImport(ImportDeclaration importDeclaration) {
 		return null;
 	}

Resolves the given annotation type declaration and returns the binding for it.

The implementation of AnnotationTypeMemberDeclaration.resolveBinding forwards to this method. How the declaration resolves is often a function of the context in which the declaration node is embedded as well as the declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
member the annotation type member declaration of interest
Returns:
the binding for the given annotation type member declaration, or null if no binding is available
Since:
3.0
 
 		return null;
 	}

Resolves the given method declaration and returns the binding for it.

The implementation of MethodDeclaration.resolveBinding forwards to this method. How the method resolves is often a function of the context in which the method declaration node is embedded as well as the method declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
method the method or constructor declaration of interest
Returns:
the binding for the given method declaration, or null if no binding is available
 
 		return null;
 	}

Resolves the given method invocation and returns the binding for it.

The implementation of MethodInvocation.resolveMethodBinding forwards to this method. How the method resolves is often a function of the context in which the method invocation node is embedded as well as the method invocation subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
method the method invocation of interest
Returns:
the binding for the given method invocation, or null if no binding is available
 
 		return null;
 	}

Resolves the given method invocation and returns the binding for it.

The implementation of MethodInvocation.resolveMethodBinding forwards to this method. How the method resolves is often a function of the context in which the method invocation node is embedded as well as the method invocation subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
method the method invocation of interest
Returns:
the binding for the given method invocation, or null if no binding is available
 
 		return null;
 	}

Resolves the given name and returns the type binding for it.

The implementation of Name.resolveBinding forwards to this method. How the name resolves is often a function of the context in which the name node is embedded as well as the name itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
name the name of interest
Returns:
the binding for the name, or null if no binding is available
 
 		return null;
 	}

Resolves the given package declaration and returns the binding for it.

The implementation of PackageDeclaration.resolveBinding forwards to this method.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
pkg the package declaration of interest
Returns:
the binding for the given package declaration, or null if no binding is available
 
 		return null;
 	}

Resolves the given reference and returns the binding for it.

The implementation of MemberRef.resolveBinding forwards to this method. How the name resolves is often a function of the context in which the name node is embedded as well as the name itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
ref the reference of interest
Returns:
the binding for the reference, or null if no binding is available
Since:
3.0
 
 		return null;
 	}

Resolves the given member value pair and returns the binding for it.

The implementation of MemberValuePair.resolveMemberValuePairBinding forwards to this method. How the name resolves is often a function of the context in which the name node is embedded as well as the name itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
memberValuePair the member value pair of interest
Returns:
the binding for the member value pair, or null if no binding is available
Since:
3.2
 
 		return null;
 	}

Resolves the given reference and returns the binding for it.

The implementation of MethodRef.resolveBinding forwards to this method. How the name resolves is often a function of the context in which the name node is embedded as well as the name itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
ref the reference of interest
Returns:
the binding for the reference, or null if no binding is available
Since:
3.0
 
 		return null;
 	}

Resolves the given annotation type declaration and returns the binding for it.

The implementation of AnnotationTypeDeclaration.resolveBinding forwards to this method. How the declaration resolves is often a function of the context in which the declaration node is embedded as well as the declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the annotation type declaration of interest
Returns:
the binding for the given annotation type declaration, or null if no binding is available
Since:
3.0
 
 		return null;
 	}

Resolves the given anonymous class declaration and returns the binding for it.

The implementation of AnonymousClassDeclaration.resolveBinding forwards to this method. How the declaration resolves is often a function of the context in which the declaration node is embedded as well as the declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the anonymous class declaration of interest
Returns:
the binding for the given class declaration, or null if no binding is available
 
 		return null;
 	}

Resolves the given enum declaration and returns the binding for it.

The implementation of EnumDeclaration.resolveBinding forwards to this method. How the enum declaration resolves is often a function of the context in which the declaration node is embedded as well as the enum declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the enum declaration of interest
Returns:
the binding for the given enum declaration, or null if no binding is available
Since:
3.0
 
 		return null;
 	}

Resolves the given type and returns the type binding for it.

The implementation of Type.resolveBinding forwards to this method. How the type resolves is often a function of the context in which the type node is embedded as well as the type subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the type of interest
Returns:
the binding for the given type, or null if no binding is available
 
 		return null;
 	}

Resolves the given class or interface declaration and returns the binding for it.

The implementation of TypeDeclaration.resolveBinding (and TypeDeclarationStatement.resolveBinding) forwards to this method. How the type declaration resolves is often a function of the context in which the type declaration node is embedded as well as the type declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the class or interface declaration of interest
Returns:
the binding for the given type declaration, or null if no binding is available
 
 		return null;
 	}

Resolves the given type parameter and returns the type binding for the type parameter.

The implementation of TypeParameter.resolveBinding forwards to this method. How the declaration resolves is often a function of the context in which the declaration node is embedded as well as the declaration subtree itself.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
typeParameter the type paramter of interest
Returns:
the binding for the given type parameter, or null if no binding is available
Since:
3.1
 
 		return null;
 	}

Resolves the given enum constant declaration and returns the binding for the field.

The implementation of EnumConstantDeclaration.resolveVariable forwards to this method.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
enumConstant the enum constant declaration of interest
Returns:
the field binding for the given enum constant declaration, or null if no binding is available
Since:
3.0
 
 		return null;
 	}

Resolves the given variable declaration and returns the binding for it.

The implementation of VariableDeclaration.resolveBinding forwards to this method. How the variable declaration resolves is often a function of the context in which the variable declaration node is embedded as well as the variable declaration subtree itself. VariableDeclaration declarations used as local variable, formal parameter and exception variables resolve to local variable bindings; variable declarations used to declare fields resolve to field bindings.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
variable the variable declaration of interest
Returns:
the binding for the given variable declaration, or null if no binding is available
 
 		return null;
 	}

Resolves the given well known type by name and returns the type binding for it.

The implementation of AST.resolveWellKnownType forwards to this method.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
name the name of a well known type
Returns:
the corresponding type binding, or null if the named type is not considered well known or if no binding can be found for it
 
 		return null;
 	}

Resolves the given annotation instance and returns the DOM representation for it.

The implementation of Annotation.resolveAnnotationBinding() forwards to this method.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
annotation the annotation ast node of interest
Returns:
the DOM annotation representation for the given ast node, or null if none is available
 
 		return null;
 	}

Answer an array type binding with the given type binding and the given dimensions.

If the given type binding is an array binding, then the resulting dimensions is the given dimensions plus the existing dimensions of the array binding. Otherwise the resulting dimensions is the given dimensions.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
typeBinding the given type binding
dimensions the given dimensions
Returns:
an array type binding with the given type binding and the given dimensions
Throws:
java.lang.IllegalArgumentException if the type binding represents the void type binding
 
 	ITypeBinding resolveArrayType(ITypeBinding typeBindingint dimensions) {
 		return null;
 	}

Returns the compilation unit scope used by this binding resolver. Returns null if none.

Returns:
the compilation unit scope by this resolver, or null if none.
 
 		return null;
 	}

Allows the user to store information about the given old/new pair of AST nodes.

The default implementation of this method does nothing. Subclasses may reimplement.

Parameters:
newNode the new AST node
oldASTNode the old AST node
 
 	void store(ASTNode newNodeorg.eclipse.jdt.internal.compiler.ast.ASTNode oldASTNode) {
 		// default implementation: do nothing
 	}

Allows the user to update information about the given old/new pair of AST nodes.

The default implementation of this method does nothing. Subclasses may reimplement.

Parameters:
node the old AST node
newNode the new AST node
	void updateKey(ASTNode nodeASTNode newNode) {
		// default implementation: do nothing
New to GrepCode? Check out our FAQ X