Search in sources :

Example 6 with DidChangeTextDocumentParams

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

the class CompletionHandlerTest method changeDocument.

private void changeDocument(ICompilationUnit unit, String content, int version) throws JavaModelException {
    DidChangeTextDocumentParams changeParms = new DidChangeTextDocumentParams();
    VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier();
    textDocument.setUri(JDTUtils.toURI(unit));
    textDocument.setVersion(version);
    changeParms.setTextDocument(textDocument);
    TextDocumentContentChangeEvent event = new TextDocumentContentChangeEvent();
    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)

Example 7 with DidChangeTextDocumentParams

use of org.eclipse.lsp4j.DidChangeTextDocumentParams 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

DidChangeTextDocumentParams (org.eclipse.lsp4j.DidChangeTextDocumentParams)7 TextDocumentContentChangeEvent (org.eclipse.lsp4j.TextDocumentContentChangeEvent)7 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)7 Range (org.eclipse.lsp4j.Range)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Position (org.eclipse.lsp4j.Position)2 TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)2 CodeActionContext (org.eclipse.lsp4j.CodeActionContext)1 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)1 ExecuteCommandParams (org.eclipse.lsp4j.ExecuteCommandParams)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1