Class SourceRefElement

java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.aspectj.org.eclipse.jdt.internal.core.JavaElement
org.aspectj.org.eclipse.jdt.internal.core.SourceRefElement
All Implemented Interfaces:
IJavaElement, ISourceReference, org.eclipse.core.runtime.IAdaptable
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 Details

    • occurrenceCount

      public int occurrenceCount
  • Constructor Details

    • SourceRefElement

      protected SourceRefElement(JavaElement parent)
  • Method Details

    • closing

      protected void closing(Object info) throws JavaModelException
      This element is being closed. Do any necessary cleanup.
      Specified by:
      closing in class JavaElement
      Throws:
      JavaModelException
    • createElementInfo

      protected Object createElementInfo()
      Returns a new element info for this element.
      Specified by:
      createElementInfo in class JavaElement
    • copy

      public void copy(IJavaElement container, IJavaElement sibling, 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(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
    • generateInfos

      protected void generateInfos(Object info, HashMap newElements, org.eclipse.core.runtime.IProgressMonitor pm) throws JavaModelException
      Description copied from class: JavaElement
      Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable). Puts the newly created element info in the given map.
      Specified by:
      generateInfos in class JavaElement
      Throws:
      JavaModelException
    • getAnnotation

      public IAnnotation getAnnotation(String name)
    • getAnnotations

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

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

      public org.eclipse.core.resources.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(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner)
      Specified by:
      getHandleFromMemento in class JavaElement
    • getHandleMemento

      protected void getHandleMemento(StringBuffer buff)
      Overrides:
      getHandleMemento 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 or to the folder 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 org.eclipse.core.resources.IResource resource()
      Specified by:
      resource in class JavaElement
    • getSource

      public 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, either null is returned, or a source range with a -1 offset and a 0 length. SourceRange.isAvailable(ISourceRange) can be used to detect that case.

      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 org.eclipse.core.resources.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, String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Throws:
      JavaModelException
      See Also:
      ISourceManipulation
    • rename

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

      protected void toStringName(StringBuffer buffer)
      Description copied from class: JavaElement
      Debugging purposes
      Overrides:
      toStringName in class JavaElement