Package org.eclipse.lemminx.commons

## Class ModelTextDocuments<T>

- java.lang.Object
- - org.eclipse.lemminx.commons.TextDocuments<ModelTextDocument<T>>
  - - org.eclipse.lemminx.commons.ModelTextDocuments<T>

Type Parameters:
  `T` - the model type (ex : DOM Document)

    public class ModelTextDocuments<T>
    extends TextDocuments<ModelTextDocument<T>>

The cache of `TextDocument` linked to a model.

Author:
  Angelo ZERR

### Constructor Summary

Constructors
`ModelTextDocuments​(BiFunction<TextDocument,​org.eclipse.lsp4j.jsonrpc.CancelChecker,​T> parse)`

### Method Summary

All Methods Instance Methods Concrete Methods
`<R> CompletableFuture<R>` `computeModelAsync​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier, BiFunction<T,​org.eclipse.lsp4j.jsonrpc.CancelChecker,​R> code)` Get or parse the model and apply the code function which expects the model.
`<R> CompletableFuture<R>` `computeModelAsyncCompose​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier, BiFunction<T,​org.eclipse.lsp4j.jsonrpc.CancelChecker,​CompletableFuture<R>> code)` Get or parse the model and apply the code function which expects the model.
`ModelTextDocument<T>` `createDocument​(org.eclipse.lsp4j.TextDocumentItem document)`
`T` `getExistingModel​(String uri)` Returns the model of the given text document Uri and null otherwise.
`T` `getExistingModel​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier)` Returns the model of the given text document Uri and null otherwise.
`T` `getModel​(String uri)` Returns the model of the given text document Uri and null otherwise.
`T` `getModel​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier)` Returns the model of the given text document Uri and null otherwise.

### Methods inherited from class org.eclipse.lemminx.commons.TextDocuments

`all, get, get, isIncremental, onDidChangeTextDocument, onDidCloseTextDocument, onDidOpenTextDocument, setIncremental`

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

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

### Constructor Detail

#### ModelTextDocuments

    public ModelTextDocuments​(BiFunction<TextDocument,​org.eclipse.lsp4j.jsonrpc.CancelChecker,​T> parse)

### Method Detail

#### createDocument

    public ModelTextDocument<T> createDocument​(org.eclipse.lsp4j.TextDocumentItem document)

Overrides:
  `createDocument` in class `TextDocuments<ModelTextDocument<T>>`

#### getExistingModel

    public T getExistingModel​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier)

Returns the model of the given text document Uri and null otherwise.

Parameters:
  `uri` - the text document uri.
Returns:
  the model of the given text document Uri and null otherwise.

#### getExistingModel

    public T getExistingModel​(String uri)

Returns the model of the given text document Uri and null otherwise.

Parameters:
  `uri` - the text document uri.
Returns:
  the model of the given text document Uri and null otherwise.

#### getModel

    public T getModel​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier)

Returns the model of the given text document Uri and null otherwise.

Parameters:
  `uri` - the text document uri.
Returns:
  the model of the given text document Uri and null otherwise.

#### getModel

    public T getModel​(String uri)

Returns the model of the given text document Uri and null otherwise.

Parameters:
  `uri` - the text document uri.
Returns:
  the model of the given text document Uri and null otherwise.

#### computeModelAsync

    public <R> CompletableFuture<R> computeModelAsync​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier,
                                                      BiFunction<T,​org.eclipse.lsp4j.jsonrpc.CancelChecker,​R> code)

Get or parse the model and apply the code function which expects the model.

Type Parameters:
  `R` -
Parameters:
  `documentIdentifier` - the document indentifier.
  `code` - a bi function that accepts the parsedmodel and `CancelChecker` and returns the to be computed value
Returns:
  the DOM Document for a given uri in a future and then apply the given function.

#### computeModelAsyncCompose

    public <R> CompletableFuture<R> computeModelAsyncCompose​(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier,
                                                             BiFunction<T,​org.eclipse.lsp4j.jsonrpc.CancelChecker,​CompletableFuture<R>> code)

Get or parse the model and apply the code function which expects the model.

Type Parameters:
  `R` -
Parameters:
  `documentIdentifier` - the document identifier.
  `code` - a bi function that accepts the parsed model and `CancelChecker` and returns as future the to be computed value
Returns:
  the model for a given uri in a future and then apply the given function.