|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
org.aspectj.org.eclipse.jdt.internal.core.CreateElementInCUOperation
public abstract class CreateElementInCUOperation
This abstract class implements behavior common to CreateElementInCUOperations.
To create a compilation unit, or an element contained in a compilation unit, the
source code for the entire compilation unit is updated and saved.
The element being created can be positioned relative to an existing
element in the compilation unit via the methods #createAfter
and #createBefore. By default, the new element is positioned
as the last child of its parent element.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation |
|---|
JavaModelOperation.IPostAction |
| Field Summary | |
|---|---|
protected IJavaElement |
anchorElement
The element that the newly created element is positioned relative to, as described by fInsertPosition, or null
if the newly created element will be positioned
last. |
protected boolean |
creationOccurred
A flag indicating whether creation of a new element occurred. |
protected CompilationUnit |
cuAST
The compilation unit AST used for this operation |
protected static int |
INSERT_AFTER
A constant meaning to position the new element after the element defined by fAnchorElement. |
protected static int |
INSERT_BEFORE
A constant meaning to position the new element before the element defined by fAnchorElement. |
protected static int |
INSERT_LAST
A constant meaning to position the new element as the last child of its parent element. |
protected int |
insertionPolicy
One of the position constants, describing where to position the newly created element. |
| Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation |
|---|
actions, actionsEnd, actionsStart, APPEND, attributes, elementsToProcess, force, HAS_MODIFIED_RESOURCE_ATTR, isNested, KEEP_EXISTING, NO_ELEMENTS, OPERATION_STACKS, parentElements, POST_ACTION_VERBOSE, progressMonitor, REMOVEALL_APPEND, resultElements, TRUE |
| Constructor Summary | |
|---|---|
CreateElementInCUOperation(IJavaElement parentElement)
Constructs an operation that creates a Java Language Element with the specified parent, contained within a compilation unit. |
|
| Method Summary | |
|---|---|
protected void |
checkCanceled()
Only allow cancelling if this operation is not nested. |
void |
createAfter(IJavaElement sibling)
Instructs this operation to position the new element after the given sibling, or to add the new element as the last child of its parent if null. |
void |
createBefore(IJavaElement sibling)
Instructs this operation to position the new element before the given sibling, or to add the new element as the last child of its parent if null. |
protected void |
executeOperation()
Execute the operation - generate new source for the compilation unit and save the results. |
protected abstract ASTNode |
generateElementAST(ASTRewrite rewriter,
ICompilationUnit cu)
|
protected void |
generateNewCompilationUnitAST(ICompilationUnit cu)
|
protected abstract IJavaElement |
generateResultHandle()
Creates and returns the handle for the element this operation created. |
protected IJavaElement[] |
generateResultHandles()
Creates and returns the handles for the elements this operation created. |
protected abstract StructuralPropertyDescriptor |
getChildPropertyDescriptor(ASTNode parent)
|
protected ICompilationUnit |
getCompilationUnit()
Returns the compilation unit in which the new element is being created. |
protected int |
getMainAmountOfWork()
Returns the amount of work for the main task of this operation for progress reporting. |
abstract java.lang.String |
getMainTaskName()
Returns the name of the main task of this operation for progress reporting. |
protected ISchedulingRule |
getSchedulingRule()
|
protected void |
initializeDefaultPosition()
Sets the default position in which to create the new type member. |
protected void |
insertASTNode(ASTRewrite rewriter,
ASTNode parent,
ASTNode child)
Inserts the given child into the given AST, based on the position settings of this operation. |
protected CompilationUnit |
parse(ICompilationUnit cu)
|
protected void |
setAlteredName(java.lang.String newName)
Sets the name of the DOMNode that will be used to
create this new element. |
protected void |
setRelativePosition(IJavaElement sibling,
int policy)
Instructs this operation to position the new element relative to the given sibling, or to add the new element as the last child of its parent if null. |
IJavaModelStatus |
verify()
Possible failures: NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is null. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected CompilationUnit cuAST
protected static final int INSERT_LAST
protected static final int INSERT_AFTER
fAnchorElement.
protected static final int INSERT_BEFORE
fAnchorElement.
protected int insertionPolicy
protected IJavaElement anchorElement
fInsertPosition, or null
if the newly created element will be positioned
last.
protected boolean creationOccurred
false. Ensures that no deltas are generated
when creation does not occur.
| Constructor Detail |
|---|
public CreateElementInCUOperation(IJavaElement parentElement)
| Method Detail |
|---|
protected void checkCanceled()
checkCanceled in class JavaModelOperationIProgressMonitor#isCanceledpublic void createAfter(IJavaElement sibling)
null.
public void createBefore(IJavaElement sibling)
null.
protected void executeOperation()
throws JavaModelException
executeOperation in class JavaModelOperationJavaModelException - if the operation is unable to completeprotected abstract StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent)
protected abstract ASTNode generateElementAST(ASTRewrite rewriter,
ICompilationUnit cu)
throws JavaModelException
JavaModelException
protected void generateNewCompilationUnitAST(ICompilationUnit cu)
throws JavaModelException
JavaModelExceptionprotected abstract IJavaElement generateResultHandle()
protected IJavaElement[] generateResultHandles()
protected ICompilationUnit getCompilationUnit()
protected int getMainAmountOfWork()
public abstract java.lang.String getMainTaskName()
protected ISchedulingRule getSchedulingRule()
getSchedulingRule in class JavaModelOperationprotected void initializeDefaultPosition()
protected void insertASTNode(ASTRewrite rewriter,
ASTNode parent,
ASTNode child)
throws JavaModelException
JavaModelExceptioncreateAfter(IJavaElement),
createBefore(IJavaElement)
protected CompilationUnit parse(ICompilationUnit cu)
throws JavaModelException
JavaModelExceptionprotected void setAlteredName(java.lang.String newName)
DOMNode that will be used to
create this new element.
Used by the CopyElementsOperation for renaming.
Only used for CreateTypeMemberOperation
protected void setRelativePosition(IJavaElement sibling,
int policy)
throws java.lang.IllegalArgumentException
null. The position
must be one of the position constants.
java.lang.IllegalArgumentExceptionpublic IJavaModelStatus verify()
null.
verify in class JavaModelOperationIJavaModelStatus,
JavaConventions
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||