org.eclipse.handly.model.impl.support

## Class ElementManager

- java.lang.Object
- - org.eclipse.handly.model.impl.support.ElementManager

-     public class ElementManager
      extends java.lang.Object

  Manages element handle/body relationships for a Handly-based model. Generally, each model will have its own instance of the element manager.

  An instance of this class is safe for use by multiple threads.

  See Also:
    `IElementImplSupport.getElementManager_()`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IBodyCache` | `cache`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ElementManager(IBodyCache cache)` Constructs an element manager with the given body cache.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `close(IElement element, IContext context)` Attempts to close the given element according to options specified in the given context.
    `ISourceFile[]` | `getWorkingCopies()` Returns the working copies currently managed by this manager.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cache

          protected final IBodyCache cache

  - ### Constructor Detail

    - #### ElementManager

          public ElementManager(IBodyCache cache)

      Constructs an element manager with the given body cache.
      Parameters:
        `cache` - the body cache to be used by the element manager (not `null`)

  - ### Method Detail

    - #### getWorkingCopies

          public final ISourceFile[] getWorkingCopies()

      Returns the working copies currently managed by this manager. Performs atomically.

      Note that the result may immediately become stale if other threads can create or destroy working copies that are managed by this manager.

      Returns:
        the working copies currently managed by this manager (never `null`)

    - #### close

          protected void close(IElement element,
                               IContext context)

      Attempts to close the given element according to options specified in the given context. If the current state of an open element does not permit closing (e.g., a working copy), it remains open. Closing of an element generally involves closing its children and removal of its body from the body cache. This method is called under the element manager lock.

      Subclasses may override this method, but are not intended to invoke it.

      This implementation invokes `((IElementImplExtension)element).`close_`(context)`.

      Parameters:
        `element` - the element that needs closing (never `null`)
        `context` - the operation context (never `null`)

Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0