public class CreatePackageDeclarationOperation extends CreateElementInCUOperation
This operation adds/replaces a package declaration in an existing compilation unit. If the compilation unit already includes the specified package declaration, it is not generated (it does not generate duplicates).
Required Attributes:
JavaModelOperation.IPostAction| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
name
The name of the package declaration being created
|
anchorElement, creationOccurred, cuAST, INSERT_AFTER, INSERT_BEFORE, INSERT_LAST, insertionPolicyactions, 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 and Description |
|---|
CreatePackageDeclarationOperation(java.lang.String name,
ICompilationUnit parentElement)
When executed, this operation will add a package declaration to the given compilation unit.
|
| Modifier and Type | Method and Description |
|---|---|
protected ASTNode |
generateElementAST(ASTRewrite rewriter,
ICompilationUnit cu) |
protected IJavaElement |
generateResultHandle()
Creates and returns the handle for the element this operation created.
|
protected StructuralPropertyDescriptor |
getChildPropertyDescriptor(ASTNode parent) |
java.lang.String |
getMainTaskName()
Returns the name of the main task of this operation for
progress reporting.
|
protected void |
initializeDefaultPosition()
Sets the correct position for new package declaration:
before the first import
if no imports, before the first type
if no type - first thing in the CU
|
IJavaModelStatus |
verify()
Possible failures:
NO_ELEMENTS_TO_PROCESS - no compilation unit was supplied to the operation
INVALID_NAME - a name supplied to the operation was not a valid
package declaration name.
|
checkCanceled, createAfter, createBefore, executeOperation, generateNewCompilationUnitAST, generateResultHandles, getCompilationUnit, getMainAmountOfWork, getSchedulingRule, insertASTNode, parse, setAlteredName, setRelativePositionaddAction, addDelta, addReconcileDelta, applyTextEdit, beginTask, canModifyRoots, commonVerify, copyResources, createFile, createFolder, deleteEmptyPackageFragment, deleteResource, deleteResources, done, equalsOneOf, executeNestedOperation, firstActionWithID, getAttribute, getCompilationUnitFor, getCurrentOperationStack, getDocument, getElementToProcess, getJavaModel, 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, workedpublic CreatePackageDeclarationOperation(java.lang.String name,
ICompilationUnit parentElement)
protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent)
getChildPropertyDescriptor in class CreateElementInCUOperationprotected ASTNode generateElementAST(ASTRewrite rewriter, ICompilationUnit cu) throws JavaModelException
generateElementAST in class CreateElementInCUOperationJavaModelExceptionprotected IJavaElement generateResultHandle()
generateResultHandle in class CreateElementInCUOperationpublic java.lang.String getMainTaskName()
CreateElementInCUOperationgetMainTaskName in class CreateElementInCUOperationCreateElementInCUOperation.getMainTaskName()protected void initializeDefaultPosition()
initializeDefaultPosition in class CreateElementInCUOperationpublic IJavaModelStatus verify()
verify in class CreateElementInCUOperationIJavaModelStatus,
JavaConventions