org.aspectj.org.eclipse.jdt.internal.core
Class CreateImportOperation

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
      extended by org.aspectj.org.eclipse.jdt.internal.core.CreateElementInCUOperation
          extended by org.aspectj.org.eclipse.jdt.internal.core.CreateImportOperation

public class CreateImportOperation
extends CreateElementInCUOperation

This operation adds an import declaration to an existing compilation unit. If the compilation unit already includes the specified import declaration, the import is not generated (it does not generate duplicates). Note that it is valid to specify both a single-type import and an on-demand import for the same package, for example "java.io.File" and "java.io.*", in which case both are preserved since the semantics of this are not the same as just importing "java.io.*". Importing "java.lang.*", or the package in which the compilation unit is defined, are not treated as special cases. If they are specified, they are included in the result.

Required Attributes:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
JavaModelOperation.IPostAction
 
Field Summary
protected  int flags
           
protected  java.lang.String importName
           
 
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.CreateElementInCUOperation
anchorElement, creationOccurred, cuAST, INSERT_AFTER, INSERT_BEFORE, INSERT_LAST, insertionPolicy
 
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
CreateImportOperation(java.lang.String importName, ICompilationUnit parentElement, int flags)
          When executed, this operation will add an import to the given compilation unit.
 
Method Summary
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 the new import: after the last import if no imports, before the first type if no type, after the package statement and if no package statement - first thing in the CU
 IJavaModelStatus verify()
          Possible failures: NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is null.
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.CreateElementInCUOperation
checkCanceled, createAfter, createBefore, executeOperation, generateNewCompilationUnitAST, generateResultHandles, getCompilationUnit, getMainAmountOfWork, getSchedulingRule, insertASTNode, parse, setAlteredName, setRelativePosition
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
addAction, 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, worked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

importName

protected java.lang.String importName

flags

protected int flags
Constructor Detail

CreateImportOperation

public CreateImportOperation(java.lang.String importName,
                             ICompilationUnit parentElement,
                             int flags)
When executed, this operation will add an import to the given compilation unit.

Method Detail

getChildPropertyDescriptor

protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent)
Specified by:
getChildPropertyDescriptor in class CreateElementInCUOperation

generateElementAST

protected ASTNode generateElementAST(ASTRewrite rewriter,
                                     ICompilationUnit cu)
                              throws JavaModelException
Specified by:
generateElementAST in class CreateElementInCUOperation
Throws:
JavaModelException

generateResultHandle

protected IJavaElement generateResultHandle()
Description copied from class: CreateElementInCUOperation
Creates and returns the handle for the element this operation created.

Specified by:
generateResultHandle in class CreateElementInCUOperation
See Also:
CreateElementInCUOperation.generateResultHandle()

getMainTaskName

public java.lang.String getMainTaskName()
Description copied from class: CreateElementInCUOperation
Returns the name of the main task of this operation for progress reporting.

Specified by:
getMainTaskName in class CreateElementInCUOperation
See Also:
CreateElementInCUOperation.getMainTaskName()

initializeDefaultPosition

protected void initializeDefaultPosition()
Sets the correct position for the new import:

verify

public IJavaModelStatus verify()
Possible failures:

Overrides:
verify in class CreateElementInCUOperation
See Also:
IJavaModelStatus, JavaConventions