Class SharedASTProviderCore
- java.lang.Object
-
- org.eclipse.jdt.core.manipulation.SharedASTProviderCore
-
public class SharedASTProviderCore extends Object
TheSharedASTProviderCoreprovides access to theAST rootused 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:
- the AST has a
ITypeRootas source:CompilationUnit.getTypeRoot()is not null. - the
AST API levelisAPI level 14or higher - the AST has bindings resolved (
AST.hasResolvedBindings()) statementandbindingsrecovery are enabled
It is possible that in the future a higher API level is used, or that future options will be enabled.
The returned AST is shared. It is marked as
ASTNode.PROTECTand must not be modified. Clients are advised to use the non-modifyingASTRewriteto get update scripts.This class is not intended to be subclassed or instantiated by clients.
- Since:
- 1.11
- Restriction:
- This class is not intended to be instantiated by clients.
- the AST has a
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSharedASTProviderCore.WAIT_FLAGWait flag class.
-
Field Summary
Fields Modifier and Type Field Description static SharedASTProviderCore.WAIT_FLAGWAIT_ACTIVE_ONLYWait flag indicating that a client requesting an AST only wants to wait for the shared AST of the active editor.static SharedASTProviderCore.WAIT_FLAGWAIT_NOWait flag indicating that a client requesting an AST only wants the already available shared AST.static SharedASTProviderCore.WAIT_FLAGWAIT_YESWait flag indicating that a client requesting an AST wants to wait until an AST is ready.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSharedASTProviderCore()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CompilationUnitgetAST(ITypeRoot element, SharedASTProviderCore.WAIT_FLAG waitFlag, IProgressMonitor progressMonitor)Returns a compilation unit AST for the given Java element.
-
-
-
Field Detail
-
WAIT_YES
public static final SharedASTProviderCore.WAIT_FLAG WAIT_YES
Wait flag indicating that a client requesting an AST wants to wait until an AST is ready.An AST will be created by this AST provider if the shared AST is not for the given Java element.
-
WAIT_ACTIVE_ONLY
public static final SharedASTProviderCore.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.No AST will be created by the AST provider.
-
WAIT_NO
public static final SharedASTProviderCore.WAIT_FLAG WAIT_NO
Wait flag indicating that a client requesting an AST only wants the already available shared AST.No AST will be created by the AST provider.
-
-
Method Detail
-
getAST
public static CompilationUnit getAST(ITypeRoot element, SharedASTProviderCore.WAIT_FLAG waitFlag, IProgressMonitor progressMonitor)
Returns a compilation unit AST for the given Java element. If the element is the input of the active Java editor, the AST is the shared AST.Clients are not allowed to modify the AST and must not keep any references.
- Parameters:
element- theITypeRoot, must not benullwaitFlag-WAIT_YES,WAIT_NOorWAIT_ACTIVE_ONLYprogressMonitor- the progress monitor ornull- Returns:
- the AST or
null.- If
WAIT_NOhas been specifiednullis returned if the element is not input of the current Java editor or no AST is available - If
WAIT_ACTIVE_ONLYhas been specifiednullis returned if the element is not input of the current Java editor - If
WAIT_YEShas been specified either the shared AST is returned or a new AST is created. nullwill be returned if the operation gets canceled.
- If
-
-