Class ASTRequestor
ASTParser.createASTs
.
ASTRequestor.acceptAST
is called for each of the
compilation units passed to ASTParser.createASTs
.
After all the compilation units have been processed,
ASTRequestor.acceptBindings
is called for each
of the binding keys passed to ASTParser.createASTs
.
This class is intended to be subclassed by clients. AST requestors are serially reusable, but neither reentrant nor thread-safe.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptAST
(ICompilationUnit source, CompilationUnit ast) Accepts an AST corresponding to the compilation unit.void
acceptBinding
(String bindingKey, IBinding binding) Accepts a binding corresponding to the binding key.final IBinding[]
createBindings
(String[] bindingKeys) Resolves bindings for the given binding keys.
-
Constructor Details
-
ASTRequestor
protected ASTRequestor()Creates a new instance.
-
-
Method Details
-
acceptAST
Accepts an AST corresponding to the compilation unit. That is,ast
is 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
Accepts a binding corresponding to the binding key. That is,binding
is the binding forbindingKey
;binding
isnull
if 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, ornull
if none
-
createBindings
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,
null
is 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
acceptAST
callback, there are implementation limitations concerning the look up of binding keys representing local elements. In some cases, the binding is unavailable, andnull
will be returned. This is only an issue during anacceptAST
callback, 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 ofacceptAST
callbacks, or for top-level types and their members even withinacceptAST
callbacks.- Parameters:
bindingKeys
- the binding keys to look up- Returns:
- a list of bindings paralleling the
bindingKeys
parameter, withnull
entries for keys that could not be resolved
-