Search in sources :

Example 1 with DidSaveTextDocumentParams

use of org.eclipse.lsp4j.DidSaveTextDocumentParams in project sonarlint-core by SonarSource.

the class ServerMainTest method analyzeSimpleJsFileOnSave.

@Test
public void analyzeSimpleJsFileOnSave() throws Exception {
    String uri = getUri("foo.js");
    lsProxy.getTextDocumentService().didSave(new DidSaveTextDocumentParams(new TextDocumentIdentifier(uri), "function foo() {\n  alert('toto');\n}"));
    assertThat(waitForDiagnostics(uri)).extracting("range.start.line", "range.start.character", "range.end.line", "range.end.character", "code", "source", "message", "severity").containsExactly(tuple(1, 2, 1, 15, "javascript:S1442", "sonarlint", "Remove this usage of alert(...). (javascript:S1442)", DiagnosticSeverity.Information));
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) DidSaveTextDocumentParams(org.eclipse.lsp4j.DidSaveTextDocumentParams) Test(org.junit.Test)

Example 2 with DidSaveTextDocumentParams

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

the class DocumentLifeCycleHandlerTest method saveDocument.

private void saveDocument(ICompilationUnit cu) throws Exception {
    DidSaveTextDocumentParams saveParms = new DidSaveTextDocumentParams();
    TextDocumentIdentifier textDocument = new TextDocumentIdentifier();
    textDocument.setUri(JDTUtils.toURI(cu));
    saveParms.setTextDocument(textDocument);
    saveParms.setText(cu.getSource());
    lifeCycleHandler.didSave(saveParms);
    waitForBackgroundJobs();
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) DidSaveTextDocumentParams(org.eclipse.lsp4j.DidSaveTextDocumentParams)

Aggregations

DidSaveTextDocumentParams (org.eclipse.lsp4j.DidSaveTextDocumentParams)2 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)2 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)2 Test (org.junit.Test)1