Search in sources :

Example 16 with TextDocumentContentChangeEvent

use of org.eclipse.lsp4j.TextDocumentContentChangeEvent in project eclipse.jdt.ls by eclipse.

the class DocumentLifeCycleHandlerTest method changeDocument.

private void changeDocument(ICompilationUnit cu, String content, int version, Range range) throws JavaModelException {
    DidChangeTextDocumentParams changeParms = new DidChangeTextDocumentParams();
    VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier();
    textDocument.setUri(JDTUtils.toURI(cu));
    textDocument.setVersion(version);
    changeParms.setTextDocument(textDocument);
    TextDocumentContentChangeEvent event = new TextDocumentContentChangeEvent();
    if (range != null) {
        event.setRange(range);
    }
    event.setText(content);
    List<TextDocumentContentChangeEvent> contentChanges = new ArrayList<>();
    contentChanges.add(event);
    changeParms.setContentChanges(contentChanges);
    lifeCycleHandler.didChange(changeParms);
}
Also used : DidChangeTextDocumentParams(org.eclipse.lsp4j.DidChangeTextDocumentParams) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) ArrayList(java.util.ArrayList) TextDocumentContentChangeEvent(org.eclipse.lsp4j.TextDocumentContentChangeEvent)

Aggregations

TextDocumentContentChangeEvent (org.eclipse.lsp4j.TextDocumentContentChangeEvent)16 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)9 DidChangeTextDocumentParams (org.eclipse.lsp4j.DidChangeTextDocumentParams)7 Range (org.eclipse.lsp4j.Range)7 TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)4 ArrayList (java.util.ArrayList)3 Position (org.eclipse.lsp4j.Position)3 Test (org.junit.Test)3 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 IDocument (org.eclipse.jface.text.IDocument)2 DeleteEdit (org.eclipse.text.edits.DeleteEdit)2 InsertEdit (org.eclipse.text.edits.InsertEdit)2 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)2 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)2 TextEdit (org.eclipse.text.edits.TextEdit)2 TextDocument (org.springframework.ide.vscode.commons.util.text.TextDocument)2 Path (java.nio.file.Path)1 List (java.util.List)1