Class ClassFileWorkingCopy
java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.aspectj.org.eclipse.jdt.internal.core.JavaElement
org.aspectj.org.eclipse.jdt.internal.core.Openable
org.aspectj.org.eclipse.jdt.internal.core.CompilationUnit
org.aspectj.org.eclipse.jdt.internal.core.ClassFileWorkingCopy
- All Implemented Interfaces:
IBufferChangedListener, ICodeAssist, ICompilationUnit, IJavaElement, IOpenable, IParent, ISourceManipulation, ISourceReference, ITypeRoot, IWorkingCopy, ICompilationUnit, IDependent, SuffixConstants, org.eclipse.core.runtime.IAdaptable
A working copy on an
IClassFile.-
Field Summary
FieldsFields inherited from class CompilationUnit
DOM_BASED_OPERATIONS, name, ownerFields inherited from class JavaElement
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_DELIMITER_ESCAPE, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LAMBDA_EXPRESSION, JEM_LAMBDA_METHOD, JEM_LOCALVARIABLE, JEM_METHOD, JEM_MODULAR_CLASSFILE, JEM_MODULE, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_STRING, JEM_TYPE, JEM_TYPE_PARAMETER, NO_ELEMENTS, NO_INFO, NO_STRINGSModifier and TypeFieldDescriptionstatic final charstatic final charstatic final charstatic final charstatic final charBefore ')','&'and '"' became the newest additions as delimiters, the former two were allowed as part of element attributes and possibly stored.static final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charprotected static final JavaElement[]protected static final Objectstatic final String[]Fields inherited from interface ICompilationUnit
ENABLE_BINDINGS_RECOVERY, ENABLE_STATEMENTS_RECOVERY, FORCE_PROBLEM_DETECTION, IGNORE_METHOD_BODIES, NO_ASTModifier and TypeFieldDescriptionstatic final intConstant indicating that a reconcile operation should enable the bindings recoverystatic final intConstant indicating that a reconcile operation should enable the statements recovery.static final intConstant indicating that a reconcile operation should recompute the problems even if the source hasn't changed.static final intConstant indicating that a reconcile operation could ignore to parse the method bodies.static final intConstant indicating that a reconcile operation should not return an AST.Fields inherited from interface IDependent
JAR_FILE_ENTRY_SEPARATORFields inherited from interface IJavaElement
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_MODULE, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETERModifier and TypeFieldDescriptionstatic final intConstant representing an annotation.static final intConstant representing a class file.static final intConstant representing a Java compilation unit.static final intConstant representing a field.static final intConstant representing all import declarations within a compilation unit.static final intConstant representing an import declaration within a compilation unit.static final intConstant representing a stand-alone instance or class initializer.static final intConstant representing a Java model (workspace level object).static final intConstant represents a module descriptor.static final intConstant representing a Java project.static final intConstant representing a local variable declaration.static final intConstant representing a method or constructor.static final intConstant representing a package declaration within a compilation unit.static final intConstant representing a package fragment.static final intConstant representing a package fragment root.static final intConstant representing a type (a class or interface).static final intConstant representing a type parameter declaration.Fields inherited from interface SuffixConstants
EXTENSION_aj, EXTENSION_AJ, EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, EXTENSION_jmod, EXTENSION_JMOD, SUFFIX_aj, SUFFIX_AJ, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_aj, SUFFIX_STRING_AJ, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVAModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final char[]static final char[]static final char[]static final char[]static final char[]static final char[]static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcommitWorkingCopy(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Commits the contents of this working copy to its underlying resource.Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time.char[]Answer the contents of the compilation unit.org.eclipse.core.runtime.IPathgetPath()Returns the path to the innermost resource enclosing this element.getPrimaryElement(boolean checkOwner) protected IBufferopenBuffer(org.eclipse.core.runtime.IProgressMonitor pm, IElementInfo info) Opens a buffer on the contents of this element, and returns the buffer, or returnsnullif opening fails.org.eclipse.core.resources.IResourceresource(PackageFragmentRoot root) protected voidtoStringName(StringBuilder buffer) Debugging purposesMethods inherited from class CompilationUnit
applyTextEdit, becomeWorkingCopy, becomeWorkingCopy, bufferChanged, buildStructure, calculateHashCode, canBeRemovedFromCache, canBufferBeRemovedFromCache, cloneCachingContents, close, closing, codeComplete, codeComplete, codeComplete, codeComplete, codeComplete, codeComplete, codeComplete, codeSelect, codeSelect, commit, copy, createElementInfo, createImport, createImport, createPackageDeclaration, createType, delete, destroy, discardWorkingCopy, equals, findElements, findPrimaryType, findSharedWorkingCopy, findWorkingCopy, getAllTypes, getCompilationUnit, getCorrespondingResource, getCustomOptions, getElementAt, getElementName, getElementType, getFileName, getHandleFromMemento, getHandleMementoDelimiter, getImport, getImportContainer, getImports, getMainTypeName, getModule, getModuleName, getNameRange, getOrBuildAST, getOriginal, getOriginalElement, getOwner, getPackageDeclaration, getPackageDeclarations, getPackageName, getPerWorkingCopyInfo, getPrimary, getSharedWorkingCopy, getSource, getSourceRange, getType, getTypeRoot, getTypes, getUnderlyingResource, getWorkingCopy, getWorkingCopy, getWorkingCopy, getWorkingCopy, getWorkingCopy, hasBuffer, hasResourceChanged, ignoreOptionalProblems, isBasedOn, isConsistent, isPrimary, isSourceElement, isWorkingCopy, makeConsistent, makeConsistent, move, openAncestors, originalFromClone, reconcile, reconcile, reconcile, reconcile, reconcile, rename, restore, save, setOptions, toStringInfo, updateTimeStamp, updateTimeStamp, validateCompilationUnit, validateExistenceModifier and TypeMethodDescriptionorg.eclipse.text.edits.UndoEditapplyTextEdit(org.eclipse.text.edits.TextEdit edit, org.eclipse.core.runtime.IProgressMonitor monitor) Applies a text edit to the compilation unit's buffer.voidbecomeWorkingCopy(IProblemRequestor problemRequestor, org.eclipse.core.runtime.IProgressMonitor monitor) Changes this compilation unit handle into a working copy.voidbecomeWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor) Changes this compilation unit handle into a working copy.voidbufferChanged(BufferChangedEvent event) The buffer associated with this element has changed.protected booleanbuildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.resources.IResource underlyingResource) Builds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer).protected intbooleanbooleancanBufferBeRemovedFromCache(IBuffer buffer) voidclose()Closes this element and its buffer (if any).protected voidThis element is being closed.voidcodeComplete(int offset, CompletionRequestor requestor) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.voidcodeComplete(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.voidcodeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner workingCopyOwner, org.eclipse.core.runtime.IProgressMonitor monitor) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.voidcodeComplete(int offset, CompletionRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.voidcodeComplete(int offset, ICodeCompletionRequestor requestor) Deprecated.- use codeComplete(int, ICompletionRequestor)voidcodeComplete(int offset, ICompletionRequestor requestor) Deprecated.voidcodeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner workingCopyOwner) Deprecated.codeSelect(int offset, int length) Returns the Java elements corresponding to the given selected text in this compilation unit.codeSelect(int offset, int length, WorkingCopyOwner workingCopyOwner) Returns the Java elements corresponding to the given selected text in this compilation unit.voidcommit(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Deprecated.voidcopy(IJavaElement container, IJavaElement sibling, String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Copies this element to the given container.protected CompilationUnitElementInfoReturns a new element info for this element.createImport(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.createImport(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.createPackageDeclaration(String pkg, org.eclipse.core.runtime.IProgressMonitor monitor) Creates and returns a package declaration in this compilation unit with the given package name.createType(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.voiddelete(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Deletes this element, forcing if specified and necessary.voiddestroy()Deprecated.voidChanges this compilation unit in working copy mode back to its original mode.booleanReturns true if this handle represents the same Java element as the given handle.findElements(IJavaElement element) Finds the elements in this compilation unit that correspond to the given element.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), ornullif no such a type exists.findSharedWorkingCopy(IBufferFactory factory) Deprecated.findWorkingCopy(WorkingCopyOwner workingCopyOwner) Finds the working copy for this compilation unit, given aWorkingCopyOwner.IType[]Returns all types declared in this compilation unit in the order in which they appear in the source.org.eclipse.core.resources.IResourceA compilation unit has a corresponding resource unless it is contained in a jar.Returns the table of the current custom options for this ICompilationUnit.getElementAt(int position) Returns the smallest element within this Java type root that includes the given source position (that is, a method, field, etc.), ornullif 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.Returns the name of this element.intReturns this element's kind encoded as an integer.char[]Answer the file name which defines the type.getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) protected charReturns thecharthat marks the start of this handles contribution to a memento.Returns the first import declaration in this compilation unit with the given name.Returns the import container for this compilation unit.Returns the import declarations in this compilation unit in the order in which they appear in the source.char[]Answer the name of the top level public type.Returns the module description contained in this type root or null if there is no module in this type root.char[]Returns the name of the module to which this compilation unit is associated.Returns the name range associated with this element.getOrBuildAST(WorkingCopyOwner workingCopyOwner, int focalPosition) getOriginal(IJavaElement workingCopyElement) Deprecated.Deprecated.getOwner()Returnsnullif thisICompilationUnitis the primary working copy, or thisICompilationUnitis not a working copy, otherwise theWorkingCopyOwnerReturns the first package declaration in this compilation unit with the given package name (there normally is at most one package declaration).Returns the package declarations in this compilation unit in the order in which they appear in the source.char[][]Answer the name of the package according to the directory structure or null if package consistency checks should be ignored.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.getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) Deprecated.Returns the source code associated with this element.Returns the source range associated with this element.Returns the top-level type declared in this compilation unit with the given simple type name.IType[]getTypes()Returns the top-level types declared in this compilation unit in the order in which they appear in the source.org.eclipse.core.resources.IResourceReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.Deprecated.getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, org.eclipse.core.runtime.IProgressMonitor monitor) Deprecated.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.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.getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) Deprecated.protected booleanReturns true if this element may have an associated source buffer, otherwise false.booleanReturns whether the resource of this working copy has changed since the inception of this working copy.booleanAnswer if optional problems should be ignored for this compilation unit.booleanisBasedOn(org.eclipse.core.resources.IResource resource) Deprecated.booleanSubclasses must override as required.booleanprotected booleanReturns true if this represents a source element.booleanReturns whether this element is a working copy.makeConsistent(int astLevel, boolean resolveBindings, int reconcileFlags, Map<String, CategorizedProblem[]> problems, org.eclipse.core.runtime.IProgressMonitor monitor) voidmakeConsistent(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.voidmove(IJavaElement container, IJavaElement sibling, String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Moves this element to the given container.protected voidopenAncestors(Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.runtime.IProgressMonitor monitor) org.eclipse.core.resources.IMarker[]Deprecated.voidreconcile(boolean forceProblemDetection, org.eclipse.core.runtime.IProgressMonitor monitor) Reconciles the contents of this working copy.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.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.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.voidRenames this element to the given name.voidrestore()Restores the contents of this working copy to the current contents of this working copy's original element.voidsave(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.voidsetOptions(Map<String, String> newOptions) Sets the ICompilationUnit custom options.protected voidtoStringInfo(int tab, StringBuilder buffer, Object info, boolean showResolvedInfo) Debugging purposesvoidCan be used to synchronize the internally used modification stamp to its correspondingIResources modification stamp.protected voidupdateTimeStamp(CompilationUnit original) protected org.eclipse.core.runtime.IStatusvalidateCompilationUnit(org.eclipse.core.resources.IResource resource) protected org.eclipse.core.runtime.IStatusvalidateExistence(org.eclipse.core.resources.IResource underlyingResource) Methods inherited from class Openable
closeBuffer, codeComplete, codeSelect, exists, findRecommendedLineSeparator, generateInfos, getBufferFactory, getBufferManager, getOpenable, getPackageFragmentRoot, getResource, hasUnsavedChanges, ignoreErrorStatus, isOpen, isStructureKnown, open, resource, resourceExistsModifier and TypeMethodDescriptionprotected voidClose the buffer associated with this element, if any.protected voidcodeComplete(ICompilationUnit cu, ICompilationUnit unitToSkip, int position, CompletionRequestor requestor, WorkingCopyOwner owner, ITypeRoot typeRoot, org.eclipse.core.runtime.IProgressMonitor monitor) protected IJavaElement[]codeSelect(ICompilationUnit cu, int offset, int length, WorkingCopyOwner owner) booleanexists()Returns whether this Java element exists in the model.Finds and returns the recommended line separator for this element.protected voidgenerateInfos(IElementInfo info, Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.runtime.IProgressMonitor monitor) Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable).Deprecated.protected BufferManagerReturns the buffer manager for this element.Returns the first openable parent.Find enclosing package fragment root if anyorg.eclipse.core.resources.IResourceReturns the innermost resource enclosing this element.booleanReturnstrueif this element is open and: its buffer has unsaved changes, or one of its descendants has unsaved changes, or a working copy has been created on one of this element's children and has not yet destroyedprotected booleanignoreErrorStatus(org.eclipse.core.runtime.IStatus status) booleanisOpen()Returns whether this openable is open.booleanReturns whether the structure of this element is known.voidopen(org.eclipse.core.runtime.IProgressMonitor pm) Opens this element and all parent elements that are not already open.org.eclipse.core.resources.IResourceresource()protected booleanresourceExists(org.eclipse.core.resources.IResource underlyingResource) Returns whether the corresponding resource or associated file existsMethods inherited from class JavaElement
appendEscapedDelimiter, escapeMementoName, findNode, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getClassFile, getElementInfo, getElementInfo, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getHandleMemento, getJavadocBaseLocation, getJavaModel, getJavaProject, getLibraryJavadocLocation, getOpenableParent, getParent, getPrimaryElement, getSchedulingRule, getSourceElementAt, getSourceMapper, getURLContents, hasChildren, hashCode, isAncestorOf, isReadOnly, newDoesNotExistStatus, newJavaModelException, newNotPresentException, openWhenClosed, readableName, resetHashCode, resolved, tabString, toDebugString, toString, toString, toStringAncestors, toStringChildren, toStringInfo, toStringWithAncestors, toStringWithAncestors, unresolved, validateAndCacheModifier and TypeMethodDescriptionprotected voidappendEscapedDelimiter(StringBuilder buffer, char delimiter) protected voidescapeMementoName(StringBuilder buffer, String mementoName) findNode(CompilationUnit ast) Returns theASTNodethat corresponds to thisJavaElementornullif there is no corresponding node.getAncestor(int ancestorType) Returns this Java element or the first ancestor of this element that has the given type.getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the Javadoc as HTML source if this element has attached Javadoc,nullotherwise.getChildrenOfType(int type) Returns a collection of (immediate) children of this node of the specified type.Returns the info for this handle.getElementInfo(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the info for this handle.getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner) Returns a string representation of this element handle.protected voidprotected URLReturns the Java model.Returns the Java project this element is contained in, ornullif this element is not contained in any Java project (for instance, theIJavaModelis not contained in any Java project).protected static URLReturn the first instance of IOpenable in the parent hierarchy of this element.Returns the element directly containing this element, ornullif this element has no parent.Returns the primary element (whose compilation unit is the primary compilation unit) this working copy element was created from, or this element if it is a descendant of a primary compilation unit or if it is not a descendant of a working copy (e.g.org.eclipse.core.runtime.jobs.ISchedulingRuleReturns the scheduling rule associated with this Java element.protected IJavaElementgetSourceElementAt(int position) Returns the element that is located at the given source position in this element.Returns the SourceMapper facility for this element, ornullif this element does not have a SourceMapper.protected StringgetURLContents(URL baseLoc, String docUrlValue) booleanfinal inthashCode()Returns the hash code for this Java element.booleanReturns true if this element is an ancestor of the given element, otherwise false.booleanReturns whether this Java element is read-only.protected JavaModelStatusnewJavaModelException(org.eclipse.core.runtime.IStatus status) Creates and returns a new Java model exception for this element with the given status.Creates and returns a new not present exception for this element.protected IElementInfoopenWhenClosed(IElementInfo info, boolean forceAdd, org.eclipse.core.runtime.IProgressMonitor monitor) protected voidshould not be needed but some implementations do have mutable member "occurrenceCount"protected StringtabString(int tab) Debugging purposestoString()Debugging purposesprotected voidtoString(int tab, StringBuilder buffer) Debugging purposesprotected voidtoStringAncestors(StringBuilder buffer) Debugging purposesprotected voidtoStringChildren(int tab, StringBuilder buffer, Object info) Debugging purposestoStringInfo(int tab, StringBuilder buffer) Debugging purposesDebugging purposestoStringWithAncestors(boolean showResolvedInfo) Debugging purposesprotected voidvalidateAndCache(URL baseLoc, FileNotFoundException e) Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapterMethods inherited from interface ICompilationUnit
getOptionsModifier and TypeMethodDescriptiongetOptions(boolean inheritJavaCoreOptions) Returns the table of the options for this ICompilationUnit, which includes its custom options and options inherited from its parent JavaProject.Methods inherited from interface ICompilationUnit
getDestinationPath, getExternalAnnotationPath, moduleModifier and TypeMethodDescriptiondefault Stringdefault StringgetExternalAnnotationPath(String qualifiedTypeName) Answers a path for external annotations that has been configured for the providing classpath entry, ornull.default ModuleBindingmodule(LookupEnvironment environment) Returns the binding of the module that this compilation unit is associated with.Methods inherited from interface IParent
getChildren, hasChildrenModifier and TypeMethodDescriptionReturns the immediate children of this element.booleanReturns whether this element has one or more immediate children.Methods inherited from interface ISourceReference
existsModifier and TypeMethodDescriptionbooleanexists()Returns whether this element exists in the model.
-
Field Details
-
classFile
-
-
Constructor Details
-
ClassFileWorkingCopy
-
-
Method Details
-
commitWorkingCopy
public void commitWorkingCopy(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:ICompilationUnitCommits the contents of this working copy to its underlying resource.It 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
forceparameter affects 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 resource -
false- in this case aJavaModelExceptionis thrown
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.
- Specified by:
commitWorkingCopyin interfaceICompilationUnit- Overrides:
commitWorkingCopyin classCompilationUnit- Parameters:
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- Throws:
JavaModelException- if this working copy could not commit. Reasons include:- A
CoreExceptionoccurred while updating an underlying resource - This element is not a working copy (INVALID_ELEMENT_TYPES)
- A update conflict (described above) (UPDATE_CONFLICT)
- A
- See Also:
-
-
getBuffer
Description copied from class:OpenableNote: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time. If this is the first time a request is being made for the buffer, an attempt is made to create and fill this element's buffer. If the buffer has been closed since it was first opened, the buffer is re-created.- Specified by:
getBufferin interfaceIOpenable- Overrides:
getBufferin classOpenable- Returns:
- the buffer opened for this element, or
nullif this element does not have a buffer - Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource.- See Also:
-
getContents
public char[] getContents()Description copied from interface:ICompilationUnitAnswer the contents of the compilation unit. In normal use, the contents are requested twice. Once during the initial lite parsing step, then again for the more detailed parsing step. Implementors must never return null - return an empty char[] instead, CharOperation.NO_CHAR being the candidate of choice.- Specified by:
getContentsin interfaceICompilationUnit- Overrides:
getContentsin classCompilationUnit- See Also:
-
getPath
public org.eclipse.core.runtime.IPath getPath()Description copied from interface:IJavaElementReturns the path to the innermost resource enclosing this element. If this element is not included in an external library, the path returned is the full, absolute path to the underlying resource, relative to the workbench. If this element is included in an external library, the path returned is the absolute path to the archive or to the folder in the file system. This is a handle-only method.- Specified by:
getPathin interfaceIJavaElement- Overrides:
getPathin classCompilationUnit- Returns:
- the path to the innermost resource enclosing this element
- See Also:
-
getPrimaryElement
- Overrides:
getPrimaryElementin classCompilationUnit
-
resource
- Overrides:
resourcein classCompilationUnit
-
openBuffer
protected IBuffer openBuffer(org.eclipse.core.runtime.IProgressMonitor pm, IElementInfo info) throws JavaModelException Description copied from class:OpenableOpens a buffer on the contents of this element, and returns the buffer, or returnsnullif opening fails. By default, do nothing - subclasses that have buffers must override as required.- Overrides:
openBufferin classCompilationUnit- Throws:
JavaModelException
-
toStringName
Description copied from class:JavaElementDebugging purposes- Overrides:
toStringNamein classJavaElement
-