Class Document


  • public class Document
    extends java.lang.Object
    Since:
    2.11
    • Constructor Summary

      Constructors 
      Constructor Description
      Document​(java.lang.Integer version, java.lang.String contents)  
      Document​(java.lang.Integer version, java.lang.String contents, boolean printSourceOnError)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Document applyChanges​(java.lang.Iterable<? extends org.eclipse.lsp4j.TextEdit> changes)
      Only use for testing.
      Document applyTextDocumentChanges​(java.lang.Iterable<? extends org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)
      As opposed to TextEdit[] the positions in the edits of a DidChangeTextDocumentParams refer to the state after applying the preceding edits.
      boolean equals​(java.lang.Object obj)  
      java.lang.String getContents()  
      java.lang.String getLineContent​(int lineNumber)
      Returns with the text for a certain line without the trailing end line marker.
      int getLineCount()
      Get the number of lines in the document.
      int getOffSet​(org.eclipse.lsp4j.Position position)  
      org.eclipse.lsp4j.Position getPosition​(int offset)  
      protected java.lang.String getSourceOnError()  
      java.lang.String getSubstring​(org.eclipse.lsp4j.Range range)  
      java.lang.Integer getVersion()  
      int hashCode()  
      boolean isPrintSourceOnError()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Document

        public Document​(java.lang.Integer version,
                        java.lang.String contents)
      • Document

        public Document​(java.lang.Integer version,
                        java.lang.String contents,
                        boolean printSourceOnError)
        Since:
        2.15
    • Method Detail

      • getOffSet

        public int getOffSet​(org.eclipse.lsp4j.Position position)
                      throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • getPosition

        public org.eclipse.lsp4j.Position getPosition​(int offset)
                                               throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • getLineContent

        public java.lang.String getLineContent​(int lineNumber)
                                        throws java.lang.IndexOutOfBoundsException
        Returns with the text for a certain line without the trailing end line marker. Throws an IndexOutOfBoundsException if the zero-based lineNumber argument is negative or exceeds the number of lines in the document.
        Throws:
        java.lang.IndexOutOfBoundsException
      • getSourceOnError

        protected java.lang.String getSourceOnError()
        Since:
        2.22
      • getLineCount

        public int getLineCount()
        Get the number of lines in the document. Empty document has line count: 1.
      • getSubstring

        public java.lang.String getSubstring​(org.eclipse.lsp4j.Range range)
      • applyTextDocumentChanges

        public Document applyTextDocumentChanges​(java.lang.Iterable<? extends org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)
        As opposed to TextEdit[] the positions in the edits of a DidChangeTextDocumentParams refer to the state after applying the preceding edits. See https://microsoft.github.io/language-server-protocol/specification#textedit-1 and https://github.com/microsoft/vscode/issues/23173#issuecomment-289378160 for details.
        Returns:
        a new document with an incremented version and the text document changes applied.
        Since:
        2.18
      • applyChanges

        public Document applyChanges​(java.lang.Iterable<? extends org.eclipse.lsp4j.TextEdit> changes)
        Only use for testing. All positions in the TextEdits refer to the same original document (this).
      • isPrintSourceOnError

        public boolean isPrintSourceOnError()
        Since:
        2.15
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getVersion

        public java.lang.Integer getVersion()
      • getContents

        public java.lang.String getContents()