Package org.eclipse.handly.model.impl

## Interface IElementImpl

- All Superinterfaces:
    `IElement`
  All Known Subinterfaces:
    `IElementImplExtension`, `IElementImplSupport`, `ISourceConstructImpl`, `ISourceConstructImplExtension`, `ISourceConstructImplSupport`, `ISourceElementImpl`, `ISourceElementImplSupport`, `ISourceFileImpl`, `ISourceFileImplExtension`, `ISourceFileImplSupport`
  All Known Implementing Classes:
    `BaseSourceFile`, `Element`, `FsSourceFile`, `SourceConstruct`, `SourceFile`, `WorkspaceSourceFile`

      public interface IElementImpl
      extends IElement

  All `IElement`s must implement this interface.
  Restriction:
    This interface is not intended to be extended by clients.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default boolean` | `equalsAndSameParentChain_​(IElement other)` | Returns whether this element is equal to the given element and belongs to the same parent chain as the given element.
    `boolean` | `exists_()` | Returns whether this element exists in the model.
    `IElement[]` | `getChildren_​(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor)` | Returns the immediate children of this element.
    `default <T> T[]` | `getChildrenOfType_​(java.lang.Class<T> type, IContext context, org.eclipse.core.runtime.IProgressMonitor monitor)` | Returns the immediate children of this element that have the given type.
    `default java.lang.String` | `getHandleMemento_()` | Returns a string representation of this element handle that can be used to recreate the handle via the model's `IElementHandleFactory`.
    `default java.net.URI` | `getLocationUri_()` | Returns a file system location for this element.
    `IModel` | `getModel_()` | Returns the model that owns this element.
    `java.lang.String` | `getName_()` | Returns the name of this element, or `null` if this element has no name.
    `IElement` | `getParent_()` | Returns the element directly containing this element, or `null` if this element has no parent.
    `default org.eclipse.core.resources.IResource` | `getResource_()` | Returns the innermost resource enclosing this element, or `null` if this element is not enclosed in a workspace resource.
    `default IElement` | `getRoot_()` | Returns the root element containing this element.
    `default java.lang.String` | `toDisplayString_​(IContext context)` | Returns a string representation of this element in a form suitable for displaying to the user, e.g., in message dialogs.
    `java.lang.String` | `toString_​(IContext context)` | Returns a string representation of this element in a form suitable for debugging purposes.

    - ### Methods inherited from interface org.eclipse.handly.model.IElement

      `equals, hashCode`

- - ### Method Detail

    - #### getName_

          java.lang.String getName_()

      Returns the name of this element, or `null` if this element has no name. This is a handle-only method.
      Returns:
        the element name, or `null` if this element has no name

    - #### getParent_

          IElement getParent_()

      Returns the element directly containing this element, or `null` if this element has no parent. This is a handle-only method.
      Returns:
        the parent element, or `null` if this element has no parent

    - #### getRoot_

          default IElement getRoot_()

      Returns the root element containing this element. Returns this element if it has no parent. This is a handle-only method.
      Returns:
        the root element (never `null`)

    - #### equalsAndSameParentChain_

          default boolean equalsAndSameParentChain_​(IElement other)

      Returns whether this element is equal to the given element and belongs to the same parent chain as the given element. This is a handle-only method.

      This implementation accounts for the most general case where equal elements may belong to different parent chains. For example, in JDT, equal JarPackageFragmentRoots may belong to different Java projects. Specific models can provide an optimized implementation. For example, it would be possible to just return `equals(other)` if it were known for a model that equal elements might not belong to different parent chains.

      Parameters:
        `other` - may be `null`
      Returns:
        `true` if this element is equal to the given element and belongs to the same parent chain, and `false` otherwise

    - #### getModel_

          IModel getModel_()

      Returns the model that owns this element. This is a handle-only method.
      Returns:
        the element's model (never `null`)

    - #### getHandleMemento_

          default java.lang.String getHandleMemento_()

      Returns a string representation of this element handle that can be used to recreate the handle via the model's `IElementHandleFactory`. The format of the string is not specified, but the representation is stable across workbench sessions. This is a handle-only method.
      Returns:
        the handle memento for this element, or `null` if this element is unable to provide a handle memento

    - #### getResource_

          default org.eclipse.core.resources.IResource getResource_()

      Returns the innermost resource enclosing this element, or `null` if this element is not enclosed in a workspace resource. This is a handle-only method.

      Note that it is safe to call this method and test the return value for `null` even when `org.eclipse.core.resources` bundle is not available.

      Since 1.3, this method is no longer abstract. The default implementation always returns `null`.

      Returns:
        the innermost resource enclosing this element, or `null` if this element is not enclosed in a workspace resource

    - #### getLocationUri_

          default java.net.URI getLocationUri_()

      Returns a file system location for this element. The resulting URI is suitable to passing to `EFS.getStore(URI)`. Returns `null` if no location can be determined.
      Returns:
        a file system location for this element, or `null` if no location can be determined

    - #### exists_

          boolean exists_()

      Returns whether this element exists in the model.

      Handles may or may not be backed by an actual element. Handles that are backed by an actual element are said to "exist".

      Returns:
        `true` if this element exists in the model, and `false` if this element does not exist

    - #### getChildren_

          IElement[] getChildren_​(IContext context,
                                  org.eclipse.core.runtime.IProgressMonitor monitor)
                           throws org.eclipse.core.runtime.CoreException

      Returns the immediate children of this element. Unless otherwise specified by the implementing element, the children are in no particular order.
      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:
        the immediate children of this element (never `null`). Clients must not modify the returned array.
      Throws:
        `org.eclipse.core.runtime.CoreException` - if this element does not exist or if an exception occurs while accessing its corresponding resource

    - #### getChildrenOfType_

          default <T> T[] getChildrenOfType_​(java.lang.Class<T> type,
                                             IContext context,
                                             org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException

      Returns the immediate children of this element that have the given type. Unless otherwise specified by the implementing element, the children are in no particular order.
      Parameters:
        `type` - not `null`
        `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 immediate children of this element that have the given type (never `null`). Clients must not modify the returned array.
      Throws:
        `org.eclipse.core.runtime.CoreException` - if this element does not exist or if an exception occurs while accessing its corresponding resource

    - #### toString_

          java.lang.String toString_​(IContext context)

      Returns a string representation of this element in a form suitable for debugging purposes. Clients can influence the result with format options specified in the given context; unrecognized options are ignored and an empty context is permitted.

      Implementations are encouraged to support common options defined in `ToStringOptions` and interpret the `FORMAT_STYLE` as follows:

      - `FULL` - A full representation that lists ancestors and children.
      - `LONG` - A long representation that lists children but not ancestors.
      - `MEDIUM` - A compact representation that lists ancestors but not children.
      - `SHORT` - A minimal representation that does not list ancestors or children.
      Parameters:
        `context` - not `null`
      Returns:
        a string representation of this element (never `null`)

    - #### toDisplayString_

          default java.lang.String toDisplayString_​(IContext context)

      Returns a string representation of this element in a form suitable for displaying to the user, e.g., in message dialogs. Clients can influence the result with format options specified in the given context; unrecognized options are ignored and an empty context is permitted.

      Implementations are encouraged to support common options defined in `ToStringOptions` and may interpret the `FORMAT_STYLE` as they see fit in a way that is specific to the model. No hard rules apply, but usually the string representation does not list the element's children regardless of the format style, and a `FULL` representation fully identifies the element within the model.

      Parameters:
        `context` - not `null`
      Returns:
        a string representation of this element (never `null`)