Class ASTRequestor
- java.lang.Object
-
- org.eclipse.jdt.core.dom.ASTRequestor
-
public abstract class ASTRequestor extends Object
An AST requestor handles ASTs for compilation units passed toASTParser.createASTs.ASTRequestor.acceptASTis called for each of the compilation units passed toASTParser.createASTs. After all the compilation units have been processed,ASTRequestor.acceptBindingsis called for each of the binding keys passed toASTParser.createASTs.This class is intended to be subclassed by clients. AST requestors are serially reusable, but neither reentrant nor thread-safe.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedASTRequestor()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacceptAST(ICompilationUnit source, CompilationUnit ast)Accepts an AST corresponding to the compilation unit.voidacceptBinding(String bindingKey, IBinding binding)Accepts a binding corresponding to the binding key.IBinding[]createBindings(String[] bindingKeys)Resolves bindings for the given binding keys.
-
-
-
Method Detail
-
acceptAST
public void acceptAST(ICompilationUnit source, CompilationUnit ast)
Accepts an AST corresponding to the compilation unit. That is,astis an AST forsource.The default implementation of this method does nothing. Clients should override to process the resulting AST.
- Parameters:
source- the compilation unit the ast is coming fromast- the requested abtract syntax tree
-
acceptBinding
public void acceptBinding(String bindingKey, IBinding binding)
Accepts a binding corresponding to the binding key. That is,bindingis the binding forbindingKey;bindingisnullif the key cannot be resolved.The default implementation of this method does nothing. Clients should override to process the resulting binding.
- Parameters:
bindingKey- the key of the requested bindingbinding- the requested binding, ornullif none
-
createBindings
public final IBinding[] createBindings(String[] bindingKeys)
Resolves bindings for the given binding keys. The given binding keys must have been obtained earlier usingIBinding.getKey().If a binding key cannot be resolved,
nullis put in the resulting array. Bindings can only be resolved in the dynamic scope of aASTParser.createASTs, and only ifASTParser.resolveBindings(true)was specified.Caveat: During an
acceptASTcallback, there are implementation limitations concerning the look up of binding keys representing local elements. In some cases, the binding is unavailable, andnullwill be returned. This is only an issue during anacceptASTcallback, and only when the binding key represents a local element (e.g., local variable, local class, method declared in anonymous class). There is no such limitation outside ofacceptASTcallbacks, or for top-level types and their members even withinacceptASTcallbacks.- Parameters:
bindingKeys- the binding keys to look up- Returns:
- a list of bindings paralleling the
bindingKeysparameter, withnullentries for keys that could not be resolved
-
-