Package org.eclipse.lemminx.commons

## Class TextDocument

- java.lang.Object
- - org.eclipse.lsp4j.TextDocumentItem
  - - org.eclipse.lemminx.commons.TextDocument

Direct Known Subclasses:
  `ModelTextDocument`

    public class TextDocument
    extends org.eclipse.lsp4j.TextDocumentItem

Text document extends LSP4j `TextDocumentItem` to provide methods to retrieve position.

### Constructor Summary

Constructors
`TextDocument​(String text, String uri)`
`TextDocument​(org.eclipse.lsp4j.TextDocumentItem document)`

### Method Summary

All Methods Instance Methods Concrete Methods
`org.eclipse.lsp4j.Range` `getWordRangeAt​(int textOffset, Pattern wordDefinition)`
`boolean` `isIncremental()`
`int` `lineAt​(int position)` Returns the line number the character at the given offset belongs to.
`String` `lineDelimiter​(int lineNumber)`
`int` `lineOffsetAt​(int position)`
`String` `lineText​(int lineNumber)`
`int` `offsetAt​(org.eclipse.lsp4j.Position position)`
`org.eclipse.lsp4j.Position` `positionAt​(int position)`
`void` `setIncremental​(boolean incremental)`
`void` `update​(List<org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)` Update text of the document by using the changes and according the incremental support.

### Methods inherited from class org.eclipse.lsp4j.TextDocumentItem

`equals, getLanguageId, getText, getUri, getVersion, hashCode, setLanguageId, setText, setUri, setVersion, toString`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### TextDocument

    public TextDocument​(org.eclipse.lsp4j.TextDocumentItem document)

#### TextDocument

    public TextDocument​(String text,
                        String uri)

### Method Detail

#### setIncremental

    public void setIncremental​(boolean incremental)

#### isIncremental

    public boolean isIncremental()

#### positionAt

    public org.eclipse.lsp4j.Position positionAt​(int position)
                                          throws BadLocationException

Throws:
  `BadLocationException`

#### offsetAt

    public int offsetAt​(org.eclipse.lsp4j.Position position)
                 throws BadLocationException

Throws:
  `BadLocationException`

#### lineText

    public String lineText​(int lineNumber)
                    throws BadLocationException

Throws:
  `BadLocationException`

#### lineOffsetAt

    public int lineOffsetAt​(int position)
                     throws BadLocationException

Throws:
  `BadLocationException`

#### lineAt

    public int lineAt​(int position)
               throws BadLocationException

Returns the line number the character at the given offset belongs to.

Parameters:
  `position` - the offset whose line number to be determined
Returns:
  the number of the line the offset is on
Throws:
  `BadLocationException` - if the offset is invalid in this tracker

#### lineDelimiter

    public String lineDelimiter​(int lineNumber)
                         throws BadLocationException

Throws:
  `BadLocationException`

#### getWordRangeAt

    public org.eclipse.lsp4j.Range getWordRangeAt​(int textOffset,
                                                  Pattern wordDefinition)

#### update

    public void update​(List<org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)

Update text of the document by using the changes and according the incremental support.

Parameters:
  `changes` - the text document changes.