public final class SharedASTProvider extends Object
SharedASTProvider
provides access to the AST root
used by
the current active Java editor.
For performance reasons, not more than one AST should be kept in memory at a time. Therefore, clients must not keep any references to the shared AST or its nodes or bindings.
Clients can make the following assumptions about the AST:
ITypeRoot
as source: CompilationUnit.getTypeRoot()
is not null.AST API level
is API level 8
or higherAST.hasResolvedBindings()
)statement
and bindings
recovery are enabled
The returned AST is shared. It is marked as ASTNode.PROTECT
and must not be modified. Clients are advised to use
the non-modifying ASTRewrite
to get update scripts.
This class is not intended to be subclassed or instantiated by clients.
Modifier and Type | Class and Description |
---|---|
static class |
SharedASTProvider.WAIT_FLAG
Wait flag class.
|
Modifier and Type | Field and Description |
---|---|
static SharedASTProvider.WAIT_FLAG |
WAIT_ACTIVE_ONLY
Wait flag indicating that a client requesting an AST
only wants to wait for the shared AST of the active editor.
|
static SharedASTProvider.WAIT_FLAG |
WAIT_NO
Wait flag indicating that a client requesting an AST
only wants the already available shared AST.
|
static SharedASTProvider.WAIT_FLAG |
WAIT_YES
Wait flag indicating that a client requesting an AST
wants to wait until an AST is ready.
|
Modifier and Type | Method and Description |
---|---|
static CompilationUnit |
getAST(ITypeRoot element,
SharedASTProvider.WAIT_FLAG waitFlag,
IProgressMonitor progressMonitor)
Returns a compilation unit AST for the given Java element.
|
public static final SharedASTProvider.WAIT_FLAG WAIT_YES
An AST will be created by this AST provider if the shared AST is not for the given Java element.
public static final SharedASTProvider.WAIT_FLAG WAIT_ACTIVE_ONLY
No AST will be created by the AST provider.
public static final SharedASTProvider.WAIT_FLAG WAIT_NO
No AST will be created by the AST provider.
public static CompilationUnit getAST(ITypeRoot element, SharedASTProvider.WAIT_FLAG waitFlag, IProgressMonitor progressMonitor)
Clients are not allowed to modify the AST and must not keep any references.
element
- the ITypeRoot
, must not be null
waitFlag
- WAIT_YES
, WAIT_NO
or WAIT_ACTIVE_ONLY
progressMonitor
- the progress monitor or null
null
.
WAIT_NO
has been specified null
is returned if the
element is not input of the current Java editor or no AST is availableWAIT_ACTIVE_ONLY
has been specified null
is returned if
the element is not input of the current Java editorWAIT_YES
has been specified either the shared AST is returned or a
new AST is created.null
will be returned if the operation gets canceled.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.