Class CreateTypeMemberOperation
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
org.aspectj.org.eclipse.jdt.internal.core.CreateElementInCUOperation
org.aspectj.org.eclipse.jdt.internal.core.CreateTypeMemberOperation
- All Implemented Interfaces:
org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.ICoreRunnable, org.eclipse.core.runtime.IProgressMonitor
- Direct Known Subclasses:
CreateFieldOperation, CreateInitializerOperation, CreateMethodOperation, CreateTypeOperation
Implements functionality common to
operations that create type members.
-
Nested Class Summary
Nested classes/interfaces inherited from class JavaModelOperation
JavaModelOperation.IPostAction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe name of theASTNodethat may be used to create this new element.protected ASTNodeThe AST node representing the element that this operation created.protected StringThe source code for the new member.Fields inherited from class CreateElementInCUOperation
anchorElement, creationOccurred, cuAST, INSERT_AFTER, INSERT_BEFORE, INSERT_LAST, insertionPolicyModifier and TypeFieldDescriptionprotected IJavaElementThe element that the newly created element is positioned relative to, as described byfInsertPosition, ornullif the newly created element will be positioned last.protected booleanA flag indicating whether creation of a new element occurred.protected CompilationUnitThe compilation unit AST used for this operationprotected static final intA constant meaning to position the new element after the element defined byfAnchorElement.protected static final intA constant meaning to position the new element before the element defined byfAnchorElement.protected static final intA constant meaning to position the new element as the last child of its parent element.protected intOne of the position constants, describing where to position the newly created element.Fields inherited from class 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, TRUEModifier and TypeFieldDescriptionprotected JavaModelOperation.IPostAction[]protected intprotected intprotected static final intprotected HashMapprotected IJavaElement[]The elements this operation operates on, ornullif this operation does not operate on specific elements.protected booleanConflict resolution policy - by default do not force (fail on a conflict).static final Stringprotected booleanA flag indicating whether this operation is nested.protected static final intprotected static final IJavaElement[]An empty collection ofIJavaElements - the common empty result if no elements are created, or if this operation is not actually executed.protected static final ThreadLocalprotected IJavaElement[]The parent elements this operation operates with ornullif this operation does not operate with specific parent elements.protected static booleanorg.eclipse.core.runtime.SubMonitorThe progress monitor passed into this operationprotected static final intprotected IJavaElement[]The elements created by this operation - empty until the operation actually creates elements.static final StringFields inherited from interface org.eclipse.core.runtime.IProgressMonitor
UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionCreateTypeMemberOperation(IJavaElement parentElement, String source, boolean force) When executed, this operation will create a type member in the given parent element with the specified source. -
Method Summary
Modifier and TypeMethodDescriptionprotected ASTNodegenerateElementAST(ASTRewrite rewriter, ICompilationUnit cu) protected StringGenerates anASTNodebased on the source of this operation when there is likely a syntax error in the source.protected StructuralPropertyDescriptorgetChildPropertyDescriptor(ASTNode parent) protected ITypegetType()Returns the IType the member is to be created in.protected abstract SimpleNamerename(ASTNode node, SimpleName newName) protected voidsetAlteredName(String newName) Sets the name of theASTNodethat will be used to create this new element.verify()Possible failures: NO_ELEMENTS_TO_PROCESS - the parent element supplied to the operation isnull.protected IJavaModelStatusVerify for a name collision in the destination container.Methods inherited from class CreateElementInCUOperation
checkCanceled, createAfter, createBefore, executeOperation, generateNewCompilationUnitAST, generateResultHandle, generateResultHandles, getCompilationUnit, getMainAmountOfWork, getMainTaskName, getSchedulingRule, initializeDefaultPosition, insertASTNode, parse, setRelativePositionModifier and TypeMethodDescriptionprotected voidOnly allow cancelling if this operation is not nested.voidcreateAfter(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 ifnull.voidcreateBefore(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 ifnull.protected voidExecute the operation - generate new source for the compilation unit and save the results.protected voidprotected abstract IJavaElementCreates and returns the handle for the element this operation created.protected IJavaElement[]Creates and returns the handles for the elements this operation created.protected ICompilationUnitReturns the compilation unit in which the new element is being created.protected intReturns the amount of work for the main task of this operation for progress reporting.abstract StringReturns the name of the main task of this operation for progress reporting.protected org.eclipse.core.runtime.jobs.ISchedulingRuleprotected voidSets the default position in which to create the new type member.protected voidinsertASTNode(ASTRewrite rewriter, ASTNode parent, ASTNode child) Inserts the given child into the given AST, based on the position settings of this operation.protected CompilationUnitprotected voidsetRelativePosition(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 ifnull.Methods inherited from class JavaModelOperation
addAction, addDelta, addReconcileDelta, applyTextEdit, beginTask, canModifyRoots, commonVerify, copyResources, createFile, createFolder, deleteEmptyPackageFragment, deleteResource, deleteResources, done, equalsOneOf, executeNestedOperation, firstActionWithID, getAttribute, getCompilationUnitFor, getCurrentOperationStack, getDocument, getElementToProcess, getJavaModel, getLatestASTLevel, getNestedFolders, getParentElement, getParentElements, getResultElements, getSubProgressMonitor, hasModifiedResource, internalWorked, isCanceled, isReadOnly, isTopLevelOperation, moveResources, newJavaElementDelta, popOperation, postAction, prefixesOneOf, pushOperation, removeAllPostAction, removeReconcileDelta, run, runOperation, runPostActions, setAttribute, setCanceled, setNested, setTaskName, subTask, workedModifier and TypeMethodDescriptionprotected voidprotected voidaddDelta(IJavaElementDelta delta) protected voidaddReconcileDelta(ICompilationUnit workingCopy, IJavaElementDelta delta) protected voidapplyTextEdit(ICompilationUnit cu, org.eclipse.text.edits.TextEdit edits) voidprotected booleanprotected IJavaModelStatusCommon code used to verify the elements this operation is processing.protected voidcopyResources(org.eclipse.core.resources.IResource[] resources, org.eclipse.core.runtime.IPath container) Convenience method to copy resourcesprotected voidcreateFile(org.eclipse.core.resources.IContainer folder, String name, byte[] contents, boolean forceFlag) Convenience method to create a fileprotected voidcreateFolder(org.eclipse.core.resources.IContainer parentFolder, String name, boolean forceFlag) Convenience method to create a folderprotected voiddeleteEmptyPackageFragment(IPackageFragment fragment, boolean forceFlag, org.eclipse.core.resources.IResource rootResource) Convenience method to delete an empty package fragmentprotected voiddeleteResource(org.eclipse.core.resources.IResource resource, int flags) Convenience method to delete a resourceprotected voiddeleteResources(org.eclipse.core.resources.IResource[] resources, boolean forceFlag) Convenience method to delete resourcesvoiddone()protected booleanequalsOneOf(org.eclipse.core.runtime.IPath path, org.eclipse.core.runtime.IPath[] otherPaths) voidexecuteNestedOperation(JavaModelOperation operation, int subWorkAmount) Convenience method to run an operation within this operationprotected intfirstActionWithID(String id, int start) protected static ObjectgetAttribute(Object key) protected ICompilationUnitgetCompilationUnitFor(IJavaElement element) Returns the compilation unit the given element is contained in, or the element itself (if it is a compilation unit), otherwisenull.protected static ArrayListprotected org.eclipse.jface.text.IDocumentprotected IJavaElementReturns the element to which this operation applies, ornullif not applicable.Returns the Java Model this operation is operating in.protected intprotected org.eclipse.core.runtime.IPath[]protected IJavaElementReturns the parent element to which this operation applies, ornullif not applicable.protected IJavaElement[]Returns the parent elements to which this operation applies, ornullif not applicable.Returns the elements created by this operation.protected org.eclipse.core.runtime.IProgressMonitorgetSubProgressMonitor(int workAmount) Creates and returns a subprogress monitor if appropriate.booleanReturns whether this operation has performed any resource modifications.voidinternalWorked(double work) booleanbooleanReturnstrueif this operation performs no resource modifications, otherwisefalse.protected booleanprotected voidmoveResources(org.eclipse.core.resources.IResource[] resources, org.eclipse.core.runtime.IPath container) Convenience method to move resourcesCreates and returns a newIJavaElementDeltaon the Java Model.protected JavaModelOperationprotected voidpostAction(JavaModelOperation.IPostAction action, int insertionMode) protected booleanprefixesOneOf(org.eclipse.core.runtime.IPath path, org.eclipse.core.runtime.IPath[] otherPaths) protected voidpushOperation(JavaModelOperation operation) protected voidremoveAllPostAction(String actionID) protected voidremoveReconcileDelta(ICompilationUnit workingCopy) voidrun(org.eclipse.core.runtime.IProgressMonitor monitor) Runs this operation and registers any deltas created.voidrunOperation(org.eclipse.core.runtime.IProgressMonitor monitor) Main entry point for Java Model operations.protected voidprotected static voidsetAttribute(Object key, Object attribute) voidsetCanceled(boolean b) protected voidsetNested(boolean nested) Sets whether this operation is nested or not.voidsetTaskName(String name) voidvoidworked(int work) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IProgressMonitor
clearBlocked, setBlocked, slice
-
Field Details
-
source
The source code for the new member. -
alteredName
The name of theASTNodethat may be used to create this new element. Used by theCopyElementsOperationfor renaming -
createdNode
The AST node representing the element that this operation created.
-
-
Constructor Details
-
CreateTypeMemberOperation
When executed, this operation will create a type member in the given parent element with the specified source.
-
-
Method Details
-
getChildPropertyDescriptor
- Specified by:
getChildPropertyDescriptorin classCreateElementInCUOperation
-
generateElementAST
protected ASTNode generateElementAST(ASTRewrite rewriter, ICompilationUnit cu) throws JavaModelException - Specified by:
generateElementASTin classCreateElementInCUOperation- Throws:
JavaModelException
-
rename
-
generateSyntaxIncorrectAST
Generates anASTNodebased on the source of this operation when there is likely a syntax error in the source. Returns the source used to generate this node. -
getType
Returns the IType the member is to be created in. -
setAlteredName
Sets the name of theASTNodethat will be used to create this new element. Used by theCopyElementsOperationfor renaming- Overrides:
setAlteredNamein classCreateElementInCUOperation
-
verify
Possible failures:- NO_ELEMENTS_TO_PROCESS - the parent element supplied to the operation is
null. - INVALID_CONTENTS - The source is
nullor has serious syntax errors. - NAME_COLLISION - A name collision occurred in the destination
- Overrides:
verifyin classCreateElementInCUOperation- See Also:
- NO_ELEMENTS_TO_PROCESS - the parent element supplied to the operation is
-
verifyNameCollision
Verify for a name collision in the destination container.
-