Package org.eclipse.handly.model.impl.support

# Class ElementManager

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

public class ElementManager extends 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
  Description
  `protected final IBodyCache`
  `cache`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `close(IElement element, IContext context)`
  Attempts to close the given element according to options specified in the given context.
  `final 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 Details

  - ### cache

    protected final IBodyCache cache

- ## Constructor Details

  - ### 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 Details

  - ### 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`)