org.eclipse.wst.jsdt.core.dom

## Class ASTRequestor

- java.lang.Object
- - org.eclipse.wst.jsdt.core.dom.ASTRequestor

    public abstract class ASTRequestor
    extends java.lang.Object

An AST requestor handles ASTs for javaScript units passed to `ASTParser.createASTs`.

`ASTRequestor.acceptAST` is called for each of the javaScript units passed to `ASTParser.createASTs`. After all the javaScript 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.

See Also:
  `Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.`

### Constructor Summary

Constructors
`protected` `ASTRequestor()` Creates a new instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `acceptAST(IJavaScriptUnit source, JavaScriptUnit ast)` Accepts an AST corresponding to the javaScript unit.
`void` `acceptBinding(java.lang.String bindingKey, IBinding binding)` Accepts a binding corresponding to the binding key.
`IBinding[]` `createBindings(java.lang.String[] bindingKeys)` Resolves bindings for the given binding keys.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ASTRequestor

    protected ASTRequestor()

Creates a new instance.

### Method Detail

#### acceptAST

    public void acceptAST(IJavaScriptUnit source,
                          JavaScriptUnit ast)

Accepts an AST corresponding to the javaScript unit. That is, `ast` is an AST for `source`.

The default implementation of this method does nothing. Clients should override to process the resulting AST.

Parameters:
  `source` - the javaScript unit the ast is coming from
  `ast` - the requested abtract syntax tree

#### acceptBinding

    public void acceptBinding(java.lang.String bindingKey,
                              IBinding binding)

Accepts a binding corresponding to the binding key. That is, `binding` is the binding for `bindingKey`; `binding` is `null` 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 binding
  `binding` - the requested binding, or `null` if none

#### createBindings

    public final IBinding[] createBindings(java.lang.String[] bindingKeys)

Resolves bindings for the given binding keys. The given binding keys must have been obtained earlier using `IBinding.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 a `ASTParser.createASTs`, and only if `ASTParser.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, and `null` will be returned. This is only an issue during an `acceptAST` 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 of `acceptAST` callbacks, or for top-level types and their members even within `acceptAST` callbacks.

Parameters:
  `bindingKeys` - the binding keys to look up
Returns:
  a list of bindings paralleling the `bindingKeys` parameter, with `null` entries for keys that could not be resolved