|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.core.runtime.PlatformObject
org.eclipse.jdt.internal.core.JavaElement
org.eclipse.jdt.internal.core.Openable
org.eclipse.jdt.internal.core.CompilationUnit
public class CompilationUnit
ICompilationUnit| Field Summary | |
|---|---|
WorkingCopyOwner |
owner
|
| Fields inherited from class org.eclipse.jdt.internal.core.JavaElement |
|---|
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LOCALVARIABLE, JEM_METHOD, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_TYPE, JEM_TYPE_PARAMETER |
| Fields inherited from interface org.eclipse.jdt.core.ICompilationUnit |
|---|
ENABLE_BINDINGS_RECOVERY, ENABLE_STATEMENTS_RECOVERY, FORCE_PROBLEM_DETECTION, NO_AST |
| Fields inherited from interface org.eclipse.jdt.core.IJavaElement |
|---|
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER |
| Fields inherited from interface org.eclipse.jdt.internal.compiler.env.IDependent |
|---|
JAR_FILE_ENTRY_SEPARATOR |
| Fields inherited from interface org.eclipse.jdt.internal.compiler.util.SuffixConstants |
|---|
EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA |
| Constructor Summary | |
|---|---|
CompilationUnit(PackageFragment parent,
java.lang.String name,
WorkingCopyOwner owner)
Constructs a handle to a compilation unit with the given name in the specified package for the specified owner |
|
| Method Summary | |
|---|---|
org.eclipse.text.edits.UndoEdit |
applyTextEdit(org.eclipse.text.edits.TextEdit edit,
org.eclipse.core.runtime.IProgressMonitor monitor)
Applies a text edit to the compilation unit's buffer. |
void |
becomeWorkingCopy(IProblemRequestor problemRequestor,
org.eclipse.core.runtime.IProgressMonitor monitor)
Changes this compilation unit handle into a working copy. |
void |
becomeWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor)
Changes this compilation unit handle into a working copy. |
boolean |
canBeRemovedFromCache()
|
boolean |
canBufferBeRemovedFromCache(IBuffer buffer)
|
CompilationUnit |
cloneCachingContents()
|
void |
close()
Closes this element and its buffer (if any). |
void |
codeComplete(int offset,
CompletionRequestor requestor)
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. |
void |
codeComplete(int offset,
CompletionRequestor requestor,
WorkingCopyOwner workingCopyOwner)
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. |
void |
codeComplete(int offset,
ICodeCompletionRequestor requestor)
Deprecated. - use codeComplete(int, ICompletionRequestor) |
void |
codeComplete(int offset,
ICompletionRequestor requestor)
Deprecated. |
void |
codeComplete(int offset,
ICompletionRequestor requestor,
WorkingCopyOwner workingCopyOwner)
Deprecated. |
IJavaElement[] |
codeSelect(int offset,
int length)
Returns the Java elements corresponding to the given selected text in this compilation unit. |
IJavaElement[] |
codeSelect(int offset,
int length,
WorkingCopyOwner workingCopyOwner)
Returns the Java elements corresponding to the given selected text in this compilation unit. |
void |
commit(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deprecated. |
void |
commitWorkingCopy(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Commits the contents of this working copy to its underlying resource. |
void |
copy(IJavaElement container,
IJavaElement sibling,
java.lang.String rename,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Copies this element to the given container. |
IImportDeclaration |
createImport(java.lang.String importName,
IJavaElement sibling,
int flags,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates and returns an import declaration in this compilation unit with the given name. |
IImportDeclaration |
createImport(java.lang.String importName,
IJavaElement sibling,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates and returns an non-static import declaration in this compilation unit with the given name. |
IPackageDeclaration |
createPackageDeclaration(java.lang.String pkg,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates and returns a package declaration in this compilation unit with the given package name. |
IType |
createType(java.lang.String content,
IJavaElement sibling,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates and returns a type in this compilation unit with the given contents. |
void |
delete(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deletes this element, forcing if specified and necessary. |
void |
destroy()
Deprecated. |
void |
discardWorkingCopy()
Changes this compilation unit in working copy mode back to its original mode. |
boolean |
equals(java.lang.Object obj)
Returns true if this handle represents the same Java element as the given handle. |
IJavaElement[] |
findElements(IJavaElement element)
Finds the elements in this compilation unit that correspond to the given element. |
IType |
findPrimaryType()
Finds the primary type of this Java type root (that is, the type with the same name as the compilation unit, or the type of a class file), or null if no such a type exists. |
IJavaElement |
findSharedWorkingCopy(IBufferFactory factory)
Deprecated. |
ICompilationUnit |
findWorkingCopy(WorkingCopyOwner workingCopyOwner)
Finds the working copy for this compilation unit, given a WorkingCopyOwner. |
IType[] |
getAllTypes()
Returns all types declared in this compilation unit in the order in which they appear in the source. |
ICompilationUnit |
getCompilationUnit()
|
char[] |
getContents()
Answer the contents of the compilation unit. |
IResource |
getCorrespondingResource()
A compilation unit has a corresponding resource unless it is contained in a jar. |
IJavaElement |
getElementAt(int position)
Returns the smallest element within this Java type root that includes the given source position (that is, a method, field, etc.), or null if there is no element other than the Java type root
itself at the given position, or if the given position is not
within the source range of the source of this Java type root. |
java.lang.String |
getElementName()
Returns the name of this element. |
int |
getElementType()
Returns this element's kind encoded as an integer. |
char[] |
getFileName()
Answer the file name which defines the type. |
IJavaElement |
getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner workingCopyOwner)
|
IImportDeclaration |
getImport(java.lang.String importName)
Returns the first import declaration in this compilation unit with the given name. |
IImportContainer |
getImportContainer()
Returns the import container for this compilation unit. |
IImportDeclaration[] |
getImports()
Returns the import declarations in this compilation unit in the order in which they appear in the source. |
char[] |
getMainTypeName()
Answer the name of the top level public type. |
IJavaElement |
getOriginal(IJavaElement workingCopyElement)
Deprecated. |
IJavaElement |
getOriginalElement()
Deprecated. |
WorkingCopyOwner |
getOwner()
Returns the working copy owner of this working copy. |
IPackageDeclaration |
getPackageDeclaration(java.lang.String pkg)
Returns the first package declaration in this compilation unit with the given package name (there normally is at most one package declaration). |
IPackageDeclaration[] |
getPackageDeclarations()
Returns the package declarations in this compilation unit in the order in which they appear in the source. |
char[][] |
getPackageName()
Answer the name of the package according to the directory structure or null if package consistency checks should be ignored. |
org.eclipse.core.runtime.IPath |
getPath()
Returns the path to the innermost resource enclosing this element. |
JavaModelManager.PerWorkingCopyInfo |
getPerWorkingCopyInfo()
|
ICompilationUnit |
getPrimary()
Returns the primary compilation unit (whose owner is the primary owner) this working copy was created from, or this compilation unit if this a primary compilation unit. |
IJavaElement |
getPrimaryElement(boolean checkOwner)
|
IJavaElement |
getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor pm,
IBufferFactory factory,
IProblemRequestor problemRequestor)
Deprecated. |
java.lang.String |
getSource()
Returns the source code associated with this element. |
ISourceRange |
getSourceRange()
Returns the source range associated with this element. |
IType |
getType(java.lang.String typeName)
Returns the top-level type declared in this compilation unit with the given simple type name. |
ITypeRoot |
getTypeRoot()
|
IType[] |
getTypes()
Returns the top-level types declared in this compilation unit in the order in which they appear in the source. |
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains this element, or null if this element is not contained
in a resource. |
IJavaElement |
getWorkingCopy()
Deprecated. |
ICompilationUnit |
getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor)
Returns a new working copy of this compilation unit if it is a primary compilation unit, or this compilation unit if it is already a non-primary working copy. |
IJavaElement |
getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor,
IBufferFactory factory,
IProblemRequestor problemRequestor)
Deprecated. |
ICompilationUnit |
getWorkingCopy(WorkingCopyOwner workingCopyOwner,
IProblemRequestor problemRequestor,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deprecated. |
ICompilationUnit |
getWorkingCopy(WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns a shared working copy on this compilation unit or class file using the given working copy owner to create the buffer. |
boolean |
hasResourceChanged()
Returns whether the resource of this working copy has changed since the inception of this working copy. |
boolean |
isBasedOn(IResource resource)
Deprecated. |
boolean |
isConsistent()
Subclasses must override as required. |
boolean |
isPrimary()
|
boolean |
isWorkingCopy()
Returns whether this element is a working copy. |
CompilationUnit |
makeConsistent(int astLevel,
boolean resolveBindings,
int reconcileFlags,
java.util.HashMap problems,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
void |
makeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor)
Makes this element consistent with its underlying resource or buffer by updating the element's structure and properties as necessary. |
void |
move(IJavaElement container,
IJavaElement sibling,
java.lang.String rename,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Moves this element to the given container. |
CompilationUnit |
originalFromClone()
|
IMarker[] |
reconcile()
Deprecated. |
void |
reconcile(boolean forceProblemDetection,
org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles the contents of this working copy. |
CompilationUnit |
reconcile(int astLevel,
boolean forceProblemDetection,
boolean enableStatementsRecovery,
WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles the contents of this working copy, sends out a Java delta notification indicating the nature of the change of the working copy since the last time it was either reconciled or made consistent ( IOpenable.makeConsistent(IProgressMonitor)), and returns a
compilation unit AST if requested. |
CompilationUnit |
reconcile(int astLevel,
boolean forceProblemDetection,
WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles the contents of this working copy, sends out a Java delta notification indicating the nature of the change of the working copy since the last time it was either reconciled or made consistent ( IOpenable.makeConsistent(IProgressMonitor)), and returns a
compilation unit AST if requested. |
CompilationUnit |
reconcile(int astLevel,
int reconcileFlags,
WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles the contents of this working copy, sends out a Java delta notification indicating the nature of the change of the working copy since the last time it was either reconciled or made consistent ( IOpenable.makeConsistent(IProgressMonitor)), and returns a
compilation unit AST if requested. |
void |
rename(java.lang.String newName,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Renames this element to the given name. |
IResource |
resource(PackageFragmentRoot root)
|
void |
restore()
Restores the contents of this working copy to the current contents of this working copy's original element. |
void |
save(org.eclipse.core.runtime.IProgressMonitor pm,
boolean force)
Saves any changes in this element's buffer to its underlying resource via a workspace resource operation. |
| Methods inherited from class org.eclipse.jdt.internal.core.Openable |
|---|
bufferChanged, exists, findRecommendedLineSeparator, getBuffer, getBufferFactory, getOpenable, getPackageFragmentRoot, getResource, hasUnsavedChanges, isOpen, isStructureKnown, open, resource |
| Methods inherited from class org.eclipse.jdt.internal.core.JavaElement |
|---|
findNode, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getClassFile, getElementInfo, getElementInfo, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavaModel, getJavaProject, getOpenableParent, getParent, getPrimaryElement, getSchedulingRule, getSourceMapper, hasChildren, hashCode, isAncestorOf, isReadOnly, newJavaModelException, newNotPresentException, readableName, resolved, toDebugString, toString, toStringInfo, toStringWithAncestors, toStringWithAncestors, unresolved |
| Methods inherited from class org.eclipse.core.runtime.PlatformObject |
|---|
getAdapter |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.eclipse.jdt.core.IJavaElement |
|---|
exists, getAncestor, getAttachedJavadoc, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, isReadOnly, isStructureKnown |
| Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
|---|
getAdapter |
| Methods inherited from interface org.eclipse.jdt.core.IParent |
|---|
getChildren, hasChildren |
| Methods inherited from interface org.eclipse.jdt.core.IOpenable |
|---|
findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isOpen, open |
| Methods inherited from interface org.eclipse.jdt.core.ISourceReference |
|---|
exists |
| Field Detail |
|---|
public WorkingCopyOwner owner
| Constructor Detail |
|---|
public CompilationUnit(PackageFragment parent,
java.lang.String name,
WorkingCopyOwner owner)
| Method Detail |
|---|
public org.eclipse.text.edits.UndoEdit applyTextEdit(org.eclipse.text.edits.TextEdit edit,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnit
edit - the edit to applymonitor - the progress monitor to use or null if no progress should be reported
JavaModelException - if this edit can not be applied to the compilation unit's buffer. Reasons include:
IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST).IJavaModelStatusConstants.BAD_TEXT_EDIT_LOCATION).
public void becomeWorkingCopy(IProblemRequestor problemRequestor,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIBuffer is
created using this compilation unit handle's owner. Uses the primary owner if none was
specified when this compilation unit handle was created.
When switching to working copy mode, problems are reported to given
IProblemRequestor. Note that once in working copy mode, the given
IProblemRequestor is ignored. Only the original IProblemRequestor
is used to report subsequent problems.
Once in working copy mode, changes to this compilation unit or its children are done in memory.
Only the new buffer is affected. Using ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)
will bring the underlying resource in sync with this compilation unit.
If this compilation unit was already in working copy mode, an internal counter is incremented and no
other action is taken on this compilation unit. To bring this compilation unit back into the original mode
(where it reflects the underlying resource), ICompilationUnit.discardWorkingCopy() must be call as many
times as ICompilationUnit.becomeWorkingCopy(IProblemRequestor, IProgressMonitor).
problemRequestor - a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null indicating
that the client is not interested in problems.monitor - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reported
JavaModelException - if this compilation unit could not become a working copy.ICompilationUnit.discardWorkingCopy()
public void becomeWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIBuffer is
created using this compilation unit handle's owner. Uses the primary owner if none was
specified when this compilation unit handle was created.
When switching to working copy mode, problems are reported to the problem requestor of the working copy owner.
Once in working copy mode, changes to this compilation unit or its children are done in memory.
Only the new buffer is affected. Using ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)
will bring the underlying resource in sync with this compilation unit.
If this compilation unit was already in working copy mode, an internal counter is incremented and no
other action is taken on this compilation unit. To bring this compilation unit back into the original mode
(where it reflects the underlying resource), ICompilationUnit.discardWorkingCopy() must be call as many
times as ICompilationUnit.becomeWorkingCopy(IProblemRequestor, IProgressMonitor).
monitor - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reported
JavaModelException - if this compilation unit could not become a working copy.ICompilationUnit.discardWorkingCopy()public CompilationUnit cloneCachingContents()
public boolean canBeRemovedFromCache()
canBeRemovedFromCache in class Openablepublic boolean canBufferBeRemovedFromCache(IBuffer buffer)
canBufferBeRemovedFromCache in class Openable
public void close()
throws JavaModelException
IOpenableNote: although IOpenable.close() is exposed in the API, clients are
not expected to open and close elements - the Java model does this automatically
as elements are accessed.
close in interface IOpenableclose in class JavaElementJavaModelException - if an error occurs closing this elementIOpenable
public void codeComplete(int offset,
ICompletionRequestor requestor)
throws JavaModelException
ICodeAssistoffset
is the 0-based index of the character, after which code assist is desired.
An offset of -1 indicates to code assist at the beginning of this
compilation unit.
codeComplete in interface ICodeAssistoffset - the given offset positionrequestor - the given completion requestor
JavaModelException - if code assist could not be performed. Reasons include:ICodeAssist.codeComplete(int, ICompletionRequestor)
public void codeComplete(int offset,
ICompletionRequestor requestor,
WorkingCopyOwner workingCopyOwner)
throws JavaModelException
ICodeAssistoffset
is the 0-based index of the character, after which code assist is desired.
An offset of -1 indicates to code assist at the beginning of this
compilation unit.
It considers types in the working copies with the given owner first. In other words,
the owner's working copies will take precedence over their original compilation units
in the workspace.
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
codeComplete in interface ICodeAssistoffset - the given offset positionrequestor - the given completion requestorworkingCopyOwner - the owner of working copies that take precedence over their original compilation units
JavaModelException - if code assist could not be performed. Reasons include:ICodeAssist.codeComplete(int, ICompletionRequestor, WorkingCopyOwner)
public void codeComplete(int offset,
ICodeCompletionRequestor requestor)
throws JavaModelException
ICodeAssistoffset
is the 0-based index of the character, after which code assist is desired.
An offset of -1 indicates to code assist at the beginning of this
compilation unit.
codeComplete in interface ICodeAssistoffset - the given offset positionrequestor - the given completion requestor
JavaModelException - if code assist could not be performed. Reasons include:ICodeAssist.codeComplete(int, ICodeCompletionRequestor)
public void codeComplete(int offset,
CompletionRequestor requestor)
throws JavaModelException
ICodeAssistoffset
is the 0-based index of the character, after which code assist is desired.
An offset of -1 indicates to code assist at the beginning of this
compilation unit.
codeComplete in interface ICodeAssistoffset - the given offset positionrequestor - the given completion requestor
JavaModelException - if code assist could not be performed. Reasons include:
public void codeComplete(int offset,
CompletionRequestor requestor,
WorkingCopyOwner workingCopyOwner)
throws JavaModelException
ICodeAssistoffset
is the 0-based index of the character, after which code assist is desired.
An offset of -1 indicates to code assist at the beginning of this
compilation unit.
It considers types in the working copies with the given owner first. In other words,
the owner's working copies will take precedence over their original compilation units
in the workspace.
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
codeComplete in interface ICodeAssistoffset - the given offset positionrequestor - the given completion requestorworkingCopyOwner - the owner of working copies that take precedence over their original compilation units
JavaModelException - if code assist could not be performed. Reasons include:
public IJavaElement[] codeSelect(int offset,
int length)
throws JavaModelException
ICodeAssistoffset is the 0-based index of the first selected character.
The length is the number of selected characters.
Note that if the length is 0 and the offset is inside an identifier
or the index just after an identifier then this identifier is considered as the selection.
codeSelect in interface ICodeAssistoffset - the given offset positionlength - the number of selected characters
JavaModelException - if code resolve could not be performed. Reasons include:
ICodeAssist.codeSelect(int, int)
public IJavaElement[] codeSelect(int offset,
int length,
WorkingCopyOwner workingCopyOwner)
throws JavaModelException
ICodeAssistoffset is the 0-based index of the first selected character.
The length is the number of selected characters.
It considers types in the working copies with the given owner first. In other words,
the owner's working copies will take precedence over their original compilation units
in the workspace.
Note that if the length is 0 and the offset is inside an identifier
or the index just after an identifier then this identifier is considered as the selection.
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
codeSelect in interface ICodeAssistoffset - the given offset positionlength - the number of selected charactersworkingCopyOwner - the owner of working copies that take precedence over their original compilation units
JavaModelException - if code resolve could not be performed. Reasons include:
ICodeAssist.codeSelect(int, int, WorkingCopyOwner)
public void commit(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
IWorkingCopyIt is possible that the contents of the original resource have changed
since this working copy was created, in which case there is an update conflict.
The value of the force parameter effects the resolution of
such a conflict:
true - in this case the contents of this working copy are applied to
the underlying resource even though this working copy was created before
a subsequent change in the resourcefalse - in this case a JavaModelException is thrownSince 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
commit in interface IWorkingCopyforce - a flag to handle the cases when the contents of the original resource have changed
since this working copy was createdmonitor - the given progress monitor
JavaModelException - if this working copy could not commit. Reasons include:
CoreException occurred while updating an underlying resource
IWorkingCopy.commit(boolean, IProgressMonitor)
public void commitWorkingCopy(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIt is possible that the contents of the original resource have changed
since this working copy was created, in which case there is an update conflict.
The value of the force parameter effects the resolution of
such a conflict:
true - in this case the contents of this working copy are applied to
the underlying resource even though this working copy was created before
a subsequent change in the resourcefalse - in this case a JavaModelException is thrownSince 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
force - a flag to handle the cases when the contents of the original resource have changed
since this working copy was createdmonitor - the given progress monitor
JavaModelException - if this working copy could not commit. Reasons include:
CoreException occurred while updating an underlying resource
ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)
public void copy(IJavaElement container,
IJavaElement sibling,
java.lang.String rename,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ISourceManipulation
copy in interface ISourceManipulationcontainer - the containersibling - the sibling element before which the copy should be inserted,
or null if the copy should be inserted as the last child of
the containerrename - the new name for the element, or null if the copy
retains the name of this elementforce - true if any existing child in the container with
the target name should be replaced, and false to throw an
exception in the event of a name collisionmonitor - a progress monitor
JavaModelException - if this element could not be copied. Reasons include:
CoreException occurred while updating an underlying resource
replace has been specified as false
ISourceManipulation.copy(IJavaElement, IJavaElement, String, boolean, IProgressMonitor)
public IImportDeclaration createImport(java.lang.String importName,
IJavaElement sibling,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitcreateImport(name, Flags.AccDefault, sibling, monitor).
importName - the name of the import declaration to add as defined by JLS2 7.5. (For example: "java.io.File" or
"java.awt.*")sibling - the existing element which the import declaration will be inserted immediately before (if
null , then this import will be inserted as the last import declaration.monitor - the progress monitor to notify
JavaModelException - if the element could not be created. Reasons include:
CoreException occurred while updating an underlying resource
ICompilationUnit.createImport(String, IJavaElement, IProgressMonitor)
public IImportDeclaration createImport(java.lang.String importName,
IJavaElement sibling,
int flags,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitOptionally, the new element can be positioned before the specified sibling. If no sibling is specified, the element will be inserted as the last import declaration in this 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.
Note: This API element is only needed for dealing with Java code that uses new language features of J2SE 5.0.
importName - the name of the import declaration to add as defined by JLS2 7.5. (For example: "java.io.File" or
"java.awt.*")sibling - the existing element which the import declaration will be inserted immediately before (if
null , then this import will be inserted as the last import declaration.flags - Flags.AccStatic for static imports, or
Flags.AccDefault for regular imports; other modifier flags
are ignoredmonitor - the progress monitor to notify
JavaModelException - if the element could not be created. Reasons include:
CoreException occurred while updating an underlying resource
ICompilationUnit.createImport(String, IJavaElement, int, IProgressMonitor)
public IPackageDeclaration createPackageDeclaration(java.lang.String pkg,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIf the compilation unit already includes the specified package declaration, it is not generated (it does not generate duplicates).
pkg - the name of the package declaration to add as defined by JLS2 7.4. (For example, "java.lang")monitor - the progress monitor to notify
JavaModelException - if the element could not be created. Reasons include:
CoreException occurred while updating an underlying resource
ICompilationUnit.createPackageDeclaration(String, IProgressMonitor)
public IType createType(java.lang.String content,
IJavaElement sibling,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnit
Optionally, the new type can be positioned before the specified
sibling. If sibling is null, the type will be appended
to the end of this compilation unit.
It is possible that a type with the same name already exists in this compilation unit.
The value of the force parameter effects the resolution of
such a conflict:
true - in this case the type is created with the new contentsfalse - in this case a JavaModelException is thrown
content - the source contents of the type declaration to add.sibling - the existing element which the type will be inserted immediately before (if
null, then this type will be inserted as the last type declaration.force - a boolean flag indicating how to deal with duplicatesmonitor - the progress monitor to notify
JavaModelException - if the element could not be created. Reasons include:
CoreException occurred while updating an underlying resource
ICompilationUnit.createType(String, IJavaElement, boolean, IProgressMonitor)
public void delete(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ISourceManipulation
delete in interface ISourceManipulationforce - a flag controlling whether underlying resources that are not
in sync with the local file system will be tolerated (same as the force flag
in IResource operations).monitor - a progress monitor
JavaModelException - if this element could not be deleted. Reasons include:
CoreException occurred while updating an underlying resource (CORE_EXCEPTION)ISourceManipulation.delete(boolean, IProgressMonitor)public void destroy()
IWorkingCopyIJavaModelExceptions. Has
no effect if this element is not a working copy.
If this working copy is shared, it is destroyed only when the number of calls to
destroy() is the same as the number of calls to
getSharedWorkingCopy(IProgressMonitor, IBufferFactory).
When it is destroyed, a REMOVED IJavaElementDelta is reported on this working copy.
destroy in interface IWorkingCopyIWorkingCopy.destroy()
public void discardWorkingCopy()
throws JavaModelException
ICompilationUnitThis has no effect if this compilation unit was not in working copy mode.
If ICompilationUnit.becomeWorkingCopy(IProgressMonitor) method was called several
times on this compilation unit, ICompilationUnit.discardWorkingCopy() must be called
as many times before it switches back to the original mode. Same as
for method ICompilationUnit.getWorkingCopy(IProgressMonitor).
JavaModelException - if this working copy could not return in its original mode.ICompilationUnit.becomeWorkingCopy(IProblemRequestor, IProgressMonitor)public boolean equals(java.lang.Object obj)
equals in class JavaElementObject.equals(java.lang.Object)public IJavaElement[] findElements(IJavaElement element)
ICompilationUnitnull if no such java elements can be found
or if the given element is not included in a compilation unit.
findElements in interface IWorkingCopyelement - the given element
ICompilationUnit.findElements(IJavaElement)public IType findPrimaryType()
ITypeRootnull if no such a type exists.
findPrimaryType in interface ITypeRootfindPrimaryType in interface IWorkingCopynull if no such a type existsITypeRoot.findPrimaryType()public IJavaElement findSharedWorkingCopy(IBufferFactory factory)
IWorkingCopyIBuffer factory.
If no working copy has been created for this element associated with this
buffer factory, returns null.
Users of this method must not destroy the resulting working copy.
findSharedWorkingCopy in interface IWorkingCopyfactory - the given IBuffer factory
null if noneIWorkingCopy.findSharedWorkingCopy(IBufferFactory)public ICompilationUnit findWorkingCopy(WorkingCopyOwner workingCopyOwner)
ICompilationUnitWorkingCopyOwner.
If no working copy has been created for this compilation unit associated with this
working copy owner, returns null.
Users of this method must not destroy the resulting working copy.
workingCopyOwner - the given WorkingCopyOwner
null if noneICompilationUnit.findWorkingCopy(WorkingCopyOwner)
public IType[] getAllTypes()
throws JavaModelException
ICompilationUnit
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceICompilationUnit.getAllTypes()public ICompilationUnit getCompilationUnit()
getCompilationUnit in class JavaElementIMember.getCompilationUnit()public char[] getContents()
ICompilationUnit
getContents in interface ICompilationUnitICompilationUnit.getContents()
public IResource getCorrespondingResource()
throws JavaModelException
getCorrespondingResource in interface IJavaElementgetCorrespondingResource in class Openablenull if none
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaElement.getCorrespondingResource()
public IJavaElement getElementAt(int position)
throws JavaModelException
ITypeRootnull if there is no element other than the Java type root
itself at the given position, or if the given position is not
within the source range of the source of this Java type root.
getElementAt in interface ITypeRootposition - a source position inside the Java type root
null
if none (excluding the Java type root).
JavaModelException - if the Java type root does not exist or if an
exception occurs while accessing its corresponding resourceITypeRoot.getElementAt(int)public java.lang.String getElementName()
IJavaElement
getElementName in interface IJavaElementgetElementName in class JavaElementIAdaptablepublic int getElementType()
IJavaElement
getElementType in interface IJavaElementIJavaElementIJavaElementpublic char[] getFileName()
IDependent
getFileName in interface IDependentIDependent.getFileName()
public IJavaElement getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner workingCopyOwner)
getHandleFromMemento in class JavaElementpublic IImportDeclaration getImport(java.lang.String importName)
ICompilationUnit
importName - the name of the import to find as defined by JLS2 7.5. (For example: "java.io.File"
or "java.awt.*")
ICompilationUnit.getImport(String)public IImportContainer getImportContainer()
ICompilationUnit
ICompilationUnit.getImportContainer()
public IImportDeclaration[] getImports()
throws JavaModelException
ICompilationUnit
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceICompilationUnit.getImports()public ITypeRoot getTypeRoot()
IMember.getTypeRoot()public char[] getMainTypeName()
ICompilationUnit
getMainTypeName in interface ICompilationUnitICompilationUnit.getMainTypeName()public IJavaElement getOriginal(IJavaElement workingCopyElement)
IWorkingCopynull if this is not a working copy element. This is a handle
only method, the returned element may or may not exist.
getOriginal in interface IWorkingCopyworkingCopyElement - the specified working copy element
null if this is not a working copy elementIWorkingCopy.getOriginal(IJavaElement)public IJavaElement getOriginalElement()
IWorkingCopynull if this is not a working copy.
getOriginalElement in interface IWorkingCopynull if this is not a working copyIWorkingCopy.getOriginalElement()public WorkingCopyOwner getOwner()
ICompilationUnit
nullpublic IPackageDeclaration getPackageDeclaration(java.lang.String pkg)
ICompilationUnit
pkg - the name of the package declaration as defined by JLS2 7.4. (For example, "java.lang")
ICompilationUnit.getPackageDeclaration(String)
public IPackageDeclaration[] getPackageDeclarations()
throws JavaModelException
ICompilationUnit
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceICompilationUnit.getPackageDeclarations()public char[][] getPackageName()
ICompilationUnit
getPackageName in interface ICompilationUnitICompilationUnit.getPackageName()public org.eclipse.core.runtime.IPath getPath()
IJavaElement
getPath in interface IJavaElementIJavaElement.getPath()public JavaModelManager.PerWorkingCopyInfo getPerWorkingCopyInfo()
public ICompilationUnit getPrimary()
ICompilationUnitNote that the returned primary compilation unit can be in working copy mode.
public IJavaElement getPrimaryElement(boolean checkOwner)
getPrimaryElement in class JavaElementpublic IResource resource(PackageFragmentRoot root)
public java.lang.String getSource()
throws JavaModelException
ISourceReferencegetSourceRange.
For class files, this returns the source of the entire compilation unit associated with the class file (if there is one).
getSource in interface ISourceReferencenull if this element has no
associated source code
JavaModelException - if an exception occurs while accessing its corresponding resourceISourceReference.getSource()
public ISourceRange getSourceRange()
throws JavaModelException
ISourceReferenceFor class files, this returns the range of the entire compilation unit associated with the class file (if there is one).
If this element has no associated source code null is either returned,
or a source range with a -1 offset and a 0 length.
getSourceRange in interface ISourceReferencenull or [-1, 0] if this element has no
associated source code
JavaModelException - if an exception occurs while accessing its corresponding resourceISourceReference.getSourceRange()public IType getType(java.lang.String typeName)
ICompilationUnit
typeName - the simple name of the requested type in the compilation unit
ICompilationUnit.getType(String)
public IType[] getTypes()
throws JavaModelException
ICompilationUnit
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceICompilationUnit.getTypes()
public IResource getUnderlyingResource()
throws JavaModelException
IJavaElementnull if this element is not contained
in a resource.
getUnderlyingResource in interface IJavaElementgetUnderlyingResource in class Openablenull if none
JavaModelException - if this element does not exist or if an
exception occurs while accessing its underlying resourceIJavaElement
public IJavaElement getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor pm,
IBufferFactory factory,
IProblemRequestor problemRequestor)
throws JavaModelException
IWorkingCopyObject.equals).
The life time of a shared working copy is as follows:
getSharedWorkingCopy(...) creates a new working copy for this
elementdestroy() decrements the internal counter.Note that the buffer factory will be used for the life time of this working copy, that is if the working copy is closed then reopened, this factory will be used. The buffer will be automatically initialized with the original's compilation unit content upon creation.
When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
getSharedWorkingCopy in interface IWorkingCopypm - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reportedfactory - the factory that creates a buffer that is used to get the content of the working copy
or null if the internal factory should be usedproblemRequestor - a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null indicating
that the client is not interested in problems.
JavaModelException - if the contents of this element can
not be determined.IWorkingCopy.getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
public IJavaElement getWorkingCopy()
throws JavaModelException
IWorkingCopy
Note: if intending to share a working copy amongst several clients, then
#getSharedWorkingCopy should be used instead.
When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
getWorkingCopy in interface IWorkingCopyJavaModelException - if the contents of this element can
not be determined.IWorkingCopy.getWorkingCopy()
public ICompilationUnit getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnit
Note: if intending to share a working copy amongst several clients, then
ICompilationUnit.getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
should be used instead.
When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Once done with the working copy, users of this method must discard it using
ICompilationUnit.discardWorkingCopy().
Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
monitor - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reported
JavaModelException - if the contents of this element can
not be determined.ICompilationUnit.getWorkingCopy(IProgressMonitor)
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ITypeRootObject.equals(java.lang.Object)).
The life time of a shared working copy is as follows:
ITypeRoot.getWorkingCopy(WorkingCopyOwner, IProgressMonitor)
creates a new working copy for this elementICompilationUnit.discardWorkingCopy() decrements the internal counter.Note that the working copy owner will be used for the life time of the shared working copy, that is if the working copy is closed then reopened, this owner will be used. The buffer will be automatically initialized with the original's Java type root content upon creation.
When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
A working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
Note that possible problems of this working copy are reported using this method only
if the given working copy owner returns a problem requestor for this working copy
(see WorkingCopyOwner.getProblemRequestor(ICompilationUnit)).
getWorkingCopy in interface ITypeRootworkingCopyOwner - the working copy owner that creates a buffer that is used to get the content
of the working copymonitor - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reported
JavaModelException - if the contents of this element can
not be determined.ITypeRoot.getWorkingCopy(WorkingCopyOwner, IProgressMonitor)
public IJavaElement getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor,
IBufferFactory factory,
IProblemRequestor problemRequestor)
throws JavaModelException
IWorkingCopy
Note: if intending to share a working copy amongst several clients, then
#getSharedWorkingCopy should be used instead.
When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
getWorkingCopy in interface IWorkingCopymonitor - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reportedfactory - the factory that creates a buffer that is used to get the content of the working copy
or null if the internal factory should be usedproblemRequestor - a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null indicating
that the client is not interested in problems.
JavaModelException - if the contents of this element can
not be determined.IWorkingCopy.getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner,
IProblemRequestor problemRequestor,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitObject.equals(java.lang.Object)).
The life time of a shared working copy is as follows:
ICompilationUnit.getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
creates a new working copy for this elementICompilationUnit.discardWorkingCopy() decrements the internal counter.Note that the working copy owner will be used for the life time of this working copy, that is if the working copy is closed then reopened, this owner will be used. The buffer will be automatically initialized with the original's compilation unit content upon creation.
When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
workingCopyOwner - the working copy owner that creates a buffer that is used to get the content
of the working copyproblemRequestor - a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null indicating
that the client is not interested in problems.monitor - a progress monitor used to report progress while opening this compilation unit
or null if no progress should be reported
JavaModelException - if the contents of this element can
not be determined.ICompilationUnit.getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)public boolean hasResourceChanged()
ICompilationUnitfalse if this compilation unit is not in working copy mode.
public boolean isBasedOn(IResource resource)
IWorkingCopy
isBasedOn in interface IWorkingCopyresource - this working copy's resource
IWorkingCopy.isBasedOn(IResource)public boolean isConsistent()
Openable
isConsistent in interface IOpenableisConsistent in class OpenableIOpenable.isConsistent()public boolean isPrimary()
public boolean isWorkingCopy()
ICompilationUnit
isWorkingCopy in interface IWorkingCopy
public void makeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
IOpenable
Note: Using this functionality on a working copy will interfere with any
subsequent reconciling operation. Indeed, the next
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) or
ICompilationUnit.reconcile(int, boolean, boolean, WorkingCopyOwner, IProgressMonitor)
operation will not account for changes which occurred before an
explicit use of IOpenable.makeConsistent(IProgressMonitor)
makeConsistent in interface IOpenablemakeConsistent in class Openablemonitor - the given progress monitor
JavaModelException - if the element is unable to access the contents
of its underlying resource. Reasons include:
IOpenable.makeConsistent(IProgressMonitor)
public CompilationUnit makeConsistent(int astLevel,
boolean resolveBindings,
int reconcileFlags,
java.util.HashMap problems,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
JavaModelException
public void move(IJavaElement container,
IJavaElement sibling,
java.lang.String rename,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ISourceManipulation
move in interface ISourceManipulationcontainer - the containersibling - the sibling element before which the element should be inserted,
or null if the element should be inserted as the last child of
the containerrename - the new name for the element, or null if the
element retains its nameforce - true if any existing child in the container with
the target name should be replaced, and false to throw an
exception in the event of a name collisionmonitor - a progress monitor
JavaModelException - if this element could not be moved. Reasons include:
CoreException occurred while updating an underlying resource
replace has been specified as false
ISourceManipulation.move(IJavaElement, IJavaElement, String, boolean, IProgressMonitor)public CompilationUnit originalFromClone()
public IMarker[] reconcile()
throws JavaModelException
IWorkingCopy
If the working copy hasn't changed, then no problem will be detected,
this is equivalent to IWorkingCopy#reconcile(false, null).
Compilation problems found in the new contents are notified through the
IProblemRequestor interface which was passed at
creation, and no longer as transient markers. Therefore this API will
return null.
Note: Since 3.0 added/removed/changed inner types generate change deltas.
reconcile in interface IWorkingCopynull
JavaModelException - if the contents of the original element
cannot be accessed. Reasons include:
IWorkingCopy.reconcile()
public void reconcile(boolean forceProblemDetection,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
IWorkingCopyThe boolean argument allows to force problem detection even if the working copy is already consistent.
Compilation problems found in the new contents are notified through the
IProblemRequestor interface which was passed at
creation, and no longer as transient markers. Therefore this API answers
nothing.
Note: Since 3.0 added/removed/changed inner types generate change deltas.
reconcile in interface IWorkingCopyforceProblemDetection - boolean indicating whether problem should be recomputed
even if the source hasn't changed.monitor - a progress monitor
JavaModelException - if the contents of the original element
cannot be accessed. Reasons include:
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
public CompilationUnit reconcile(int astLevel,
boolean forceProblemDetection,
WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIOpenable.makeConsistent(IProgressMonitor)), and returns a
compilation unit AST if requested.
It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.
The boolean argument allows to force problem detection even if the working copy is already consistent.
This functionality allows to specify a working copy owner which is used
during problem detection. All references contained in the working copy are
resolved against other units; for which corresponding owned working copies
are going to take precedence over their original compilation units. If
null is passed in, then the primary working copy owner is used.
Compilation problems found in the new contents are notified through the
IProblemRequestor interface which was passed at
creation, and no longer as transient markers.
Note: Since 3.0, added/removed/changed inner types generate change deltas.
If requested, a DOM AST representing the compilation unit is returned.
Its bindings are computed only if the problem requestor is active, or if the
problem detection is forced. This method returns null if the
creation of the DOM AST was not requested, or if the requested level of AST
API is not supported, or if the working copy was already consistent.
This method doesn't perform statements recovery. To recover statements with syntax
errors, ICompilationUnit.reconcile(int, boolean, boolean, WorkingCopyOwner, IProgressMonitor) must be use.
astLevel - either ICompilationUnit.NO_AST if no AST is wanted,
or the AST API level of the AST if one is wantedforceProblemDetection - boolean indicating whether problem should be
recomputed even if the source hasn't changedworkingCopyOwner - the owner of working copies that take precedence over the
original compilation units, or null if the primary working
copy owner should be usedmonitor - a progress monitor
null if not requested,
or if the requested level of AST API is not supported,
or if the working copy was consistent
JavaModelException - if the contents of the original element
cannot be accessed. Reasons include:
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
public CompilationUnit reconcile(int astLevel,
boolean forceProblemDetection,
boolean enableStatementsRecovery,
WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIOpenable.makeConsistent(IProgressMonitor)), and returns a
compilation unit AST if requested.
It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.
The boolean argument allows to force problem detection even if the working copy is already consistent.
This functionality allows to specify a working copy owner which is used
during problem detection. All references contained in the working copy are
resolved against other units; for which corresponding owned working copies
are going to take precedence over their original compilation units. If
null is passed in, then the primary working copy owner is used.
Compilation problems found in the new contents are notified through the
IProblemRequestor interface which was passed at
creation, and no longer as transient markers.
Note: Since 3.0, added/removed/changed inner types generate change deltas.
If requested, a DOM AST representing the compilation unit is returned.
Its bindings are computed only if the problem requestor is active, or if the
problem detection is forced. This method returns null if the
creation of the DOM AST was not requested, or if the requested level of AST
API is not supported, or if the working copy was already consistent.
If statements recovery is enabled then this method tries to rebuild statements with syntax error. Otherwise statements with syntax error won't be present in the returning DOM AST.
astLevel - either ICompilationUnit.NO_AST if no AST is wanted,
or the AST API level of the AST if one is wantedforceProblemDetection - boolean indicating whether problem should be
recomputed even if the source hasn't changedenableStatementsRecovery - if true statements recovery is enabled.workingCopyOwner - the owner of working copies that take precedence over the
original compilation units, or null if the primary working
copy owner should be usedmonitor - a progress monitor
null if not requested,
or if the requested level of AST API is not supported,
or if the working copy was consistent
JavaModelException - if the contents of the original element
cannot be accessed. Reasons include:
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
public CompilationUnit reconcile(int astLevel,
int reconcileFlags,
WorkingCopyOwner workingCopyOwner,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ICompilationUnitIOpenable.makeConsistent(IProgressMonitor)), and returns a
compilation unit AST if requested.
If the problem detection is forced by passing the ICompilationUnit.FORCE_PROBLEM_DETECTION bit in the given reconcile flag,
problem detection is run even if the working copy is already consistent.
It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.
This functionality allows to specify a working copy owner which is used
during problem detection. All references contained in the working copy are
resolved against other units; for which corresponding owned working copies
are going to take precedence over their original compilation units. If
null is passed in, then the primary working copy owner is used.
Compilation problems found in the new contents are notified through the
IProblemRequestor interface which was passed at
creation, and no longer as transient markers.
Note: Since 3.0, added/removed/changed inner types generate change deltas.
If requested, a DOM AST representing the compilation unit is returned.
Its bindings are computed only if the problem requestor is active, or if the
problem detection is forced. This method returns null if the
creation of the DOM AST was not requested, or if the requested level of AST
API is not supported, or if the working copy was already consistent.
If statements recovery is enabled by passing the ICompilationUnit.ENABLE_STATEMENTS_RECOVERY bit in the given reconcile flag
then this method tries to rebuild statements with syntax error. Otherwise statements with syntax error won't be
present in the returning DOM AST.
If bindings recovery is enabled by passing the ICompilationUnit.ENABLE_BINDINGS_RECOVERY bit in the given reconcile flag
then this method tries to resolve bindings even if the type resolution contains errors.
The given reconcile flags is a bit-mask of the different constants (ICompilationUnit.ENABLE_BINDINGS_RECOVERY,
ICompilationUnit.ENABLE_STATEMENTS_RECOVERY, ICompilationUnit.FORCE_PROBLEM_DETECTION). Unspecified values are left for future use.
astLevel - either ICompilationUnit.NO_AST if no AST is wanted,
or the AST API level of the AST if one is wantedreconcileFlags - the given reconcile flagsworkingCopyOwner - the owner of working copies that take precedence over the
original compilation units, or null if the primary working
copy owner should be usedmonitor - a progress monitor
null if not requested,
or if the requested level of AST API is not supported,
or if the working copy was consistent
JavaModelException - if the contents of the original element
cannot be accessed. Reasons include:
ICompilationUnit.FORCE_PROBLEM_DETECTION,
ICompilationUnit.ENABLE_BINDINGS_RECOVERY,
ICompilationUnit.ENABLE_STATEMENTS_RECOVERY
public void rename(java.lang.String newName,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws JavaModelException
ISourceManipulation
rename in interface ISourceManipulationnewName - the new name for the elementforce - true if any existing element with the target name
should be replaced, and false to throw an exception in the
event of a name collisionmonitor - a progress monitor
JavaModelException - if this element could not be renamed. Reasons include:
CoreException occurred while updating an underlying resource
replace has been specified as false
ISourceManipulation.rename(String, boolean, IProgressMonitor)
public void restore()
throws JavaModelException
ICompilationUnitNote: This is the inverse of committing the content of the
working copy to the original element with ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor).
restore in interface IWorkingCopyJavaModelException - if the contents of the original element
cannot be accessed. Reasons include:
public void save(org.eclipse.core.runtime.IProgressMonitor pm,
boolean force)
throws JavaModelException
IOpenable
The force parameter controls how this method deals with
cases where the workbench is not completely in sync with the local file system.
If false is specified, this method will only attempt
to overwrite a corresponding file in the local file system provided
it is in sync with the workbench. This option ensures there is no
unintended data loss; it is the recommended setting.
However, if true is specified, an attempt will be made
to write a corresponding file in the local file system,
overwriting any existing one if need be.
In either case, if this method succeeds, the resource will be marked
as being local (even if it wasn't before).
As a result of this operation, the element is consistent with its underlying resource or buffer.
save in interface IOpenablesave in class Openablepm - the given progress monitorforce - it controls how this method deals with
cases where the workbench is not completely in sync with the local file system
JavaModelException - if an error occurs accessing the contents
of its underlying resource. Reasons include:
IOpenable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||