org.eclipse.jdt.internal.core
Class CreateCompilationUnitOperation
java.lang.Object
org.eclipse.jdt.internal.core.JavaModelOperation
org.eclipse.jdt.internal.core.CreateCompilationUnitOperation
- All Implemented Interfaces:
- IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor
public class CreateCompilationUnitOperation
- extends JavaModelOperation
This operation creates a compilation unit (CU).
If the CU doesn't exist yet, a new compilation unit will be created with the content provided.
Otherwise the operation will override the contents of an existing CU with the new content.
Note: It is possible to create a CU automatically when creating a
class or interface. Thus, the preferred method of creating a CU is
to perform a create type operation rather than
first creating a CU and secondly creating a type inside the CU.
Required Attributes:
- The package fragment in which to create the compilation unit.
- The name of the compilation unit.
Do not include the
".java"
suffix (ex. "Object"
-
the ".java"
will be added for the name of the compilation unit.)
-
Fields inherited from interface org.eclipse.core.runtime.IProgressMonitor |
UNKNOWN |
Method Summary |
IJavaModelStatus |
verify()
Possible failures:
NO_ELEMENTS_TO_PROCESS - the package fragment supplied to the operation is
null . |
Methods inherited from class org.eclipse.jdt.internal.core.JavaModelOperation |
beginTask, done, executeNestedOperation, getJavaModel, getResultElements, hasModifiedResource, internalWorked, isCanceled, isReadOnly, newJavaElementDelta, run, runOperation, setCanceled, setTaskName, subTask, worked |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CreateCompilationUnitOperation
public CreateCompilationUnitOperation(IPackageFragment parentElement,
java.lang.String name,
java.lang.String source,
boolean force)
- When executed, this operation will create a compilation unit with the given name.
The name should have the ".java" suffix.
verify
public IJavaModelStatus verify()
- Possible failures:
- NO_ELEMENTS_TO_PROCESS - the package fragment supplied to the operation is
null
.
- INVALID_NAME - the compilation unit name provided to the operation
is
null
or has an invalid syntax
- INVALID_CONTENTS - the source specified for the compiliation unit is null
- See Also:
IJavaModelStatus