Interface ISourceElementImplSupport

    • Method Detail

      • getSourceElementInfo_

        default ISourceElementInfo getSourceElementInfo_​(IContext context,
                                                         org.eclipse.core.runtime.IProgressMonitor monitor)
                                                  throws org.eclipse.core.runtime.CoreException
        Returns an object holding cached structure and properties for this element.

        This implementation delegates to IElementImplExtension.getBody_(IContext, IProgressMonitor); it is assumed that the body implements ISourceElementInfo.

        Specified by:
        getSourceElementInfo_ in interface ISourceElementImpl
        Parameters:
        context - the operation context (not null)
        monitor - a progress monitor, or null if progress reporting is not desired. The caller must not rely on IProgressMonitor.done() having been called by the receiver
        Returns:
        an ISourceElementInfo for this element (never null)
        Throws:
        org.eclipse.core.runtime.CoreException - if this element does not exist or if an exception occurs while accessing its corresponding resource
        org.eclipse.core.runtime.OperationCanceledException - if this method is canceled
      • getSourceElementAt_

        default ISourceElement getSourceElementAt_​(int position,
                                                   IContext context,
                                                   org.eclipse.core.runtime.IProgressMonitor monitor)
                                            throws org.eclipse.core.runtime.CoreException
        Returns the smallest element within this element that includes the given source position, or null if the given position is not within the source range of this element. If no finer grained element is found at the position, this element itself is returned.

        Implementations are encouraged to support the following standard options, which may be specified in the given context:

        • BASE_SNAPSHOT - A snapshot on which the given position is based, or null if the snapshot is unknown or does not matter.

        This implementation obtains the source element info for this element and delegates to getSourceElementAt_(int, ISourceElementInfo, IContext, IProgressMonitor) if the given position is within the source range of this element as reported by checkInRange(int, ISourceElementInfo, IContext); otherwise, null is returned.

        Specified by:
        getSourceElementAt_ in interface ISourceElementImpl
        Parameters:
        position - a source position (0-based)
        context - the operation context (not null)
        monitor - a progress monitor, or null if progress reporting is not desired. The caller must not rely on IProgressMonitor.done() having been called by the receiver
        Returns:
        the innermost element enclosing the given source position, or null if none (including this element itself)
        Throws:
        org.eclipse.core.runtime.CoreException - if this element does not exist or if an exception occurs while accessing its corresponding resource
        StaleSnapshotException - if snapshot inconsistency is detected, i.e., this element's current structure and properties are based on a different snapshot
        org.eclipse.core.runtime.OperationCanceledException - if this method is canceled
      • getSourceElementAt_

        default ISourceElement getSourceElementAt_​(int position,
                                                   ISourceElementInfo info,
                                                   IContext context,
                                                   org.eclipse.core.runtime.IProgressMonitor monitor)
                                            throws org.eclipse.core.runtime.CoreException
        Returns the smallest element within this element that includes the given source position, which is known to be within the source range of this element as recorded by the given element info. If no finer grained element is found at the position, this element itself is returned.

        Implementations are encouraged to support the following standard options, which may be specified in the given context:

        • BASE_SNAPSHOT - A snapshot on which the given position is based, or null if the snapshot is unknown or does not matter.
        Parameters:
        position - a source position (0-based)
        info - an ISourceElementInfo for this element (not null)
        context - the operation context (not null)
        monitor - a progress monitor (not null). The caller must not rely on IProgressMonitor.done() having been called by the receiver
        Returns:
        the innermost element enclosing the given source position (never null)
        Throws:
        org.eclipse.core.runtime.CoreException - if an exception occurs while accessing the element's corresponding resource
        StaleSnapshotException - if snapshot inconsistency is detected
        org.eclipse.core.runtime.OperationCanceledException - if this method is canceled
      • checkInRange

        static boolean checkInRange​(int position,
                                    ISourceElementInfo info,
                                    IContext context)
        Checks whether the given position is within the element's range in the source snapshot as recorded by the given element info.

        Supports the following standard options, which may be specified in the given context:

        • BASE_SNAPSHOT - A snapshot on which the given position is based, or null if the snapshot is unknown or does not matter.
        Parameters:
        position - a source position (0-based)
        info - an ISourceElementInfo (not null)
        context - the operation context (not null)
        Returns:
        true if the given position is within the element's source range, and false otherwise
        Throws:
        StaleSnapshotException - if snapshot inconsistency is detected