org.eclipse.jdt.internal.core
Class SourceRefElement

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.jdt.internal.core.JavaElement
          extended by org.eclipse.jdt.internal.core.SourceRefElement
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IJavaElement, ISourceReference
Direct Known Subclasses:
Annotation, ImportContainer, ImportDeclaration, LocalVariable, Member, PackageDeclaration, TypeParameter

public abstract class SourceRefElement
extends JavaElement
implements ISourceReference

Abstract class for Java elements which implement ISourceReference.


Field Summary
 int occurrenceCount
           
 
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.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
 
Method Summary
 void copy(IJavaElement container, IJavaElement sibling, java.lang.String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void delete(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 boolean equals(java.lang.Object o)
          Returns true if this handle represents the same Java element as the given handle.
 ASTNode findNode(CompilationUnit ast)
          Returns the ASTNode that corresponds to this JavaElement or null if there is no corresponding node.
 IAnnotation getAnnotation(java.lang.String name)
           
 IAnnotation[] getAnnotations()
           
 ICompilationUnit getCompilationUnit()
           
 IResource getCorrespondingResource()
          Elements within compilation units and class files have no corresponding resource.
 IJavaElement getHandleFromMemento(java.lang.String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner)
           
 IJavaElement getHandleUpdatingCountFromMemento(MementoTokenizer memento, WorkingCopyOwner owner)
           
 int getOccurrenceCount()
           
 IOpenable getOpenableParent()
          Return the first instance of IOpenable in the hierarchy of this type (going up the hierarchy from this type);
 org.eclipse.core.runtime.IPath getPath()
          Returns the path to the innermost resource enclosing this element.
 java.lang.String getSource()
          Returns the source code associated with this element.
 ISourceRange getSourceRange()
          Returns the source range associated with this element.
 IResource getUnderlyingResource()
          Returns the smallest underlying resource that contains this element, or null if this element is not contained in a resource.
 boolean hasChildren()
           
 boolean isStructureKnown()
          Returns whether the structure of this element is known.
 void move(IJavaElement container, IJavaElement sibling, java.lang.String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void rename(java.lang.String newName, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 IResource resource()
           
 
Methods inherited from class org.eclipse.jdt.internal.core.JavaElement
close, exists, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getClassFile, getElementInfo, getElementInfo, getElementName, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getPrimaryElement, getResource, getSchedulingRule, getSourceMapper, 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.ISourceReference
exists
 
Methods inherited from interface org.eclipse.jdt.core.IJavaElement
getElementType
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

occurrenceCount

public int occurrenceCount
Method Detail

copy

public void copy(IJavaElement container,
                 IJavaElement sibling,
                 java.lang.String rename,
                 boolean force,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws JavaModelException
Throws:
JavaModelException
See Also:
ISourceManipulation

delete

public void delete(boolean force,
                   org.eclipse.core.runtime.IProgressMonitor monitor)
            throws JavaModelException
Throws:
JavaModelException
See Also:
ISourceManipulation

equals

public boolean equals(java.lang.Object o)
Description copied from class: JavaElement
Returns true if this handle represents the same Java element as the given handle. By default, two handles represent the same element if they are identical or if they represent the same type of element, have equal names, parents, and occurrence counts.

If a subclass has other requirements for equality, this method must be overridden.

Overrides:
equals in class JavaElement
See Also:
Object.equals(java.lang.Object)

findNode

public ASTNode findNode(CompilationUnit ast)
Returns the ASTNode that corresponds to this JavaElement or null if there is no corresponding node.

Overrides:
findNode in class JavaElement

getAnnotation

public IAnnotation getAnnotation(java.lang.String name)

getAnnotations

public IAnnotation[] getAnnotations()
                             throws JavaModelException
Throws:
JavaModelException

getCompilationUnit

public ICompilationUnit getCompilationUnit()
Overrides:
getCompilationUnit in class JavaElement
See Also:
IMember

getCorrespondingResource

public IResource getCorrespondingResource()
                                   throws JavaModelException
Elements within compilation units and class files have no corresponding resource.

Specified by:
getCorrespondingResource in interface IJavaElement
Returns:
the corresponding resource, or null if none
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IJavaElement

getHandleFromMemento

public IJavaElement getHandleFromMemento(java.lang.String token,
                                         MementoTokenizer memento,
                                         WorkingCopyOwner workingCopyOwner)
Specified by:
getHandleFromMemento in class JavaElement

getHandleUpdatingCountFromMemento

public IJavaElement getHandleUpdatingCountFromMemento(MementoTokenizer memento,
                                                      WorkingCopyOwner owner)

getOccurrenceCount

public int getOccurrenceCount()

getOpenableParent

public IOpenable getOpenableParent()
Return the first instance of IOpenable in the hierarchy of this type (going up the hierarchy from this type);

Overrides:
getOpenableParent in class JavaElement

getPath

public org.eclipse.core.runtime.IPath getPath()
Description copied from interface: IJavaElement
Returns 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 in the file system. This is a handle-only method.

Specified by:
getPath in interface IJavaElement
Returns:
the path to the innermost resource enclosing this element

resource

public IResource resource()
Specified by:
resource in class JavaElement

getSource

public java.lang.String getSource()
                           throws JavaModelException
Description copied from interface: ISourceReference
Returns the source code associated with this element. This extracts the substring from the source buffer containing this source element. This corresponds to the source range that would be returned by getSourceRange.

For class files, this returns the source of the entire compilation unit associated with the class file (if there is one).

Specified by:
getSource in interface ISourceReference
Returns:
the source code, or null if this element has no associated source code
Throws:
JavaModelException - if an exception occurs while accessing its corresponding resource
See Also:
ISourceReference

getSourceRange

public ISourceRange getSourceRange()
                            throws JavaModelException
Description copied from interface: ISourceReference
Returns the source range associated with this element.

For 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.

Specified by:
getSourceRange in interface ISourceReference
Returns:
the source range, or either null or [-1, 0] if this element has no associated source code
Throws:
JavaModelException - if an exception occurs while accessing its corresponding resource
See Also:
ISourceReference

getUnderlyingResource

public IResource getUnderlyingResource()
                                throws JavaModelException
Description copied from interface: IJavaElement
Returns the smallest underlying resource that contains this element, or null if this element is not contained in a resource.

Specified by:
getUnderlyingResource in interface IJavaElement
Returns:
the underlying resource, or null if none
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its underlying resource
See Also:
IJavaElement

hasChildren

public boolean hasChildren()
                    throws JavaModelException
Overrides:
hasChildren in class JavaElement
Throws:
JavaModelException
See Also:
IParent

isStructureKnown

public boolean isStructureKnown()
                         throws JavaModelException
Description copied from interface: IJavaElement
Returns whether the structure of this element is known. For example, for a compilation unit that has syntax errors, false 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.

Specified by:
isStructureKnown in interface IJavaElement
Returns:
true if the structure of this element is known
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IJavaElement

move

public void move(IJavaElement container,
                 IJavaElement sibling,
                 java.lang.String rename,
                 boolean force,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws JavaModelException
Throws:
JavaModelException
See Also:
ISourceManipulation

rename

public void rename(java.lang.String newName,
                   boolean force,
                   org.eclipse.core.runtime.IProgressMonitor monitor)
            throws JavaModelException
Throws:
JavaModelException
See Also:
ISourceManipulation