|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPlatformObject
org.aspectj.org.eclipse.jdt.internal.core.JavaElement
org.aspectj.org.eclipse.jdt.internal.core.Openable
public abstract class Openable
Abstract class for implementations of java elements which are IOpenable.
IJavaElement,
IOpenable| Field Summary |
|---|
| Fields inherited from class org.aspectj.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, NO_ELEMENTS, NO_INFO, parent |
| Fields inherited from interface org.aspectj.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 |
| Constructor Summary | |
|---|---|
protected |
Openable(JavaElement parent)
|
| Method Summary | |
|---|---|
void |
bufferChanged(BufferChangedEvent event)
The buffer associated with this element has changed. |
protected abstract boolean |
buildStructure(OpenableElementInfo info,
IProgressMonitor pm,
java.util.Map newElements,
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). |
boolean |
canBeRemovedFromCache()
|
boolean |
canBufferBeRemovedFromCache(IBuffer buffer)
|
protected void |
closeBuffer()
Close the buffer associated with this element, if any. |
protected void |
closing(java.lang.Object info)
This element is being closed. |
protected void |
codeComplete(ICompilationUnit cu,
ICompilationUnit unitToSkip,
int position,
CompletionRequestor requestor,
WorkingCopyOwner owner,
ITypeRoot typeRoot,
IProgressMonitor monitor)
|
protected IJavaElement[] |
codeSelect(ICompilationUnit cu,
int offset,
int length,
WorkingCopyOwner owner)
|
protected java.lang.Object |
createElementInfo()
|
boolean |
exists()
Returns whether this Java element exists in the model. |
java.lang.String |
findRecommendedLineSeparator()
Finds and returns the recommended line separator for this element. |
protected void |
generateInfos(java.lang.Object info,
java.util.HashMap newElements,
IProgressMonitor monitor)
Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable). |
IBuffer |
getBuffer()
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. |
IBufferFactory |
getBufferFactory()
Deprecated. |
protected BufferManager |
getBufferManager()
Returns the buffer manager for this element. |
IResource |
getCorrespondingResource()
Return my underlying resource. |
IOpenable |
getOpenable()
Returns the first openable parent. |
PackageFragmentRoot |
getPackageFragmentRoot()
Find enclosing package fragment root if any |
IResource |
getResource()
Returns the innermost resource enclosing this element. |
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains this element, or null if this element is not contained
in a resource. |
protected boolean |
hasBuffer()
Returns true if this element may have an associated source buffer, otherwise false. |
boolean |
hasUnsavedChanges()
Returns true if 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 destroyed
|
boolean |
isConsistent()
Subclasses must override as required. |
boolean |
isOpen()
Returns whether this openable is open. |
protected boolean |
isSourceElement()
Returns true if this represents a source element. |
boolean |
isStructureKnown()
Returns whether the structure of this element is known. |
void |
makeConsistent(IProgressMonitor monitor)
Makes this element consistent with its underlying resource or buffer by updating the element's structure and properties as necessary. |
void |
open(IProgressMonitor pm)
Opens this element and all parent elements that are not already open. |
protected void |
openAncestors(java.util.HashMap newElements,
IProgressMonitor monitor)
|
protected IBuffer |
openBuffer(IProgressMonitor pm,
java.lang.Object info)
Opens a buffer on the contents of this element, and returns the buffer, or returns null if opening fails. |
IResource |
resource()
|
protected abstract IResource |
resource(PackageFragmentRoot root)
|
protected boolean |
resourceExists(IResource underlyingResource)
Returns whether the corresponding resource or associated file exists |
void |
save(IProgressMonitor pm,
boolean force)
Saves any changes in this element's buffer to its underlying resource via a workspace resource operation. |
protected abstract IStatus |
validateExistence(IResource underlyingResource)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IOpenable |
|---|
close |
| Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IJavaElement |
|---|
getElementType, getPath |
| Constructor Detail |
|---|
protected Openable(JavaElement parent)
| Method Detail |
|---|
public void bufferChanged(BufferChangedEvent event)
bufferChanged in interface IBufferChangedListenerevent - the change eventIBufferChangedListener
protected abstract boolean buildStructure(OpenableElementInfo info,
IProgressMonitor pm,
java.util.Map newElements,
IResource underlyingResource)
throws JavaModelException
JavaModelExceptionpublic boolean canBeRemovedFromCache()
public boolean canBufferBeRemovedFromCache(IBuffer buffer)
protected void closeBuffer()
protected void closing(java.lang.Object info)
closing in class JavaElement
protected void codeComplete(ICompilationUnit cu,
ICompilationUnit unitToSkip,
int position,
CompletionRequestor requestor,
WorkingCopyOwner owner,
ITypeRoot typeRoot,
IProgressMonitor monitor)
throws JavaModelException
JavaModelException
protected IJavaElement[] codeSelect(ICompilationUnit cu,
int offset,
int length,
WorkingCopyOwner owner)
throws JavaModelException
JavaModelExceptionprotected java.lang.Object createElementInfo()
createElementInfo in class JavaElementpublic boolean exists()
IJavaElement
Java elements are handle objects that may or may not be backed by an
actual element. Java elements that are backed by an actual element are
said to "exist", and this method returns true. For Java
elements that are not working copies, it is always the case that if the
element exists, then its parent also exists (provided it has one) and
includes the element as one of its children. It is therefore possible
to navigated to any existing Java element from the root of the Java model
along a chain of existing Java elements. On the other hand, working
copies are said to exist until they are destroyed (with
IWorkingCopy.destroy). Unlike regular Java elements, a
working copy never shows up among the children of its parent element
(which may or may not exist).
exists in interface IJavaElementexists in class JavaElementtrue if this element exists in the Java model, and
false if this element does not existIJavaElement
public java.lang.String findRecommendedLineSeparator()
throws JavaModelException
IOpenableorg.eclipse.core.runtime.Platform#PREF_LINE_SEPARATOR
on this element's project or workspace is returned.
Finally if no such preference is set, the system line separator is returned.
findRecommendedLineSeparator in interface IOpenableJavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resource.
protected void generateInfos(java.lang.Object info,
java.util.HashMap newElements,
IProgressMonitor monitor)
throws JavaModelException
JavaElement
generateInfos in class JavaElementJavaModelException
public IBuffer getBuffer()
throws JavaModelException
getBuffer in interface IOpenablenull
if this element does not have a buffer
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resource.IOpenablepublic IBufferFactory getBufferFactory()
protected BufferManager getBufferManager()
public IResource getCorrespondingResource()
throws JavaModelException
getCorrespondingResource in interface IJavaElementnull if none
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaElementpublic IOpenable getOpenable()
IJavaElementnull if this element doesn't have
an openable parent.
This is a handle-only method.
getOpenable in interface IJavaElementgetOpenable in class JavaElementnull if this element doesn't have
an openable parent.
public IResource getUnderlyingResource()
throws JavaModelException
IJavaElementnull if this element is not contained
in a resource.
getUnderlyingResource in interface IJavaElementnull if none
JavaModelException - if this element does not exist or if an
exception occurs while accessing its underlying resourceIJavaElementprotected boolean hasBuffer()
public boolean hasUnsavedChanges()
throws JavaModelException
IOpenabletrue if this element is open and:
hasUnsavedChanges in interface IOpenabletrue if this element is open and:
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resource.IOpenablepublic boolean isConsistent()
isConsistent in interface IOpenableIOpenablepublic boolean isOpen()
IOpenable
isOpen in interface IOpenableIOpenableprotected boolean isSourceElement()
public boolean isStructureKnown()
throws JavaModelException
IJavaElementfalse is returned.
If the structure of an element is unknown, navigations will return reasonable
defaults. For example, getChildren for a compilation unit with
syntax errors will return a collection of the children that could be parsed.
Note: This does not imply anything about consistency with the underlying resource/buffer contents.
isStructureKnown in interface IJavaElementtrue if the structure of this element is known
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaElement
public void makeConsistent(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 IOpenablemonitor - the given progress monitor
JavaModelException - if the element is unable to access the contents
of its underlying resource. Reasons include:
IOpenable
public void open(IProgressMonitor pm)
throws JavaModelException
IOpenableNote: although IOpenable.open(IProgressMonitor) is exposed in the API, clients are
not expected to open and close elements - the Java model does this automatically
as elements are accessed.
open in interface IOpenablepm - the given progress monitor
JavaModelException - if an error occurs accessing the contents
of its underlying resource. Reasons include:
IOpenable
protected IBuffer openBuffer(IProgressMonitor pm,
java.lang.Object info)
throws JavaModelException
null if opening fails.
By default, do nothing - subclasses that have buffers
must override as required.
JavaModelExceptionpublic IResource getResource()
IJavaElementnull
is returned.
This is a handle-only method.
getResource in interface IJavaElementgetResource in class JavaElementnull if this
element is included in an external archivepublic IResource resource()
resource in class JavaElementprotected abstract IResource resource(PackageFragmentRoot root)
protected boolean resourceExists(IResource underlyingResource)
public void save(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 IOpenablepm - 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:
IOpenablepublic PackageFragmentRoot getPackageFragmentRoot()
protected abstract IStatus validateExistence(IResource underlyingResource)
protected void openAncestors(java.util.HashMap newElements,
IProgressMonitor monitor)
throws JavaModelException
JavaModelException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||