Search in sources :

Example 1 with DidOpenTextDocumentParams

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

the class ServerMainTest method analyzeSimplePhpFileOnOpen.

@Test
public void analyzeSimplePhpFileOnOpen() throws Exception {
    String uri = getUri("foo.php");
    lsProxy.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(new TextDocumentItem(uri, "php", 1, "<?php\nfunction foo() {\n  echo(\"Hello\");\n}\n?>")));
    assertThat(waitForDiagnostics(uri)).extracting("range.start.line", "range.start.character", "range.end.line", "range.end.character", "code", "source", "message", "severity").containsExactly(tuple(2, 2, 2, 6, "php:S2041", "sonarlint", "Remove the parentheses from this \"echo\" call. (php:S2041)", DiagnosticSeverity.Error));
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Test(org.junit.Test)

Example 2 with DidOpenTextDocumentParams

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

the class ServerMainTest method analyzeSimplePythonFileOnOpen.

@Test
public void analyzeSimplePythonFileOnOpen() throws Exception {
    String uri = getUri("foo.py");
    lsProxy.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(new TextDocumentItem(uri, "python", 1, "def foo():\n  print '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, 7, "python:PrintStatementUsage", "sonarlint", "Replace print statement by built-in function. (python:PrintStatementUsage)", DiagnosticSeverity.Error));
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Test(org.junit.Test)

Example 3 with DidOpenTextDocumentParams

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

the class ServerMainTest method analyzeSimpleJsFileOnOpen.

@Test
public void analyzeSimpleJsFileOnOpen() throws Exception {
    String uri = getUri("foo.js");
    lsProxy.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(new TextDocumentItem(uri, "javascript", 1, "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 : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Test(org.junit.Test)

Example 4 with DidOpenTextDocumentParams

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

the class DocumentLifeCycleHandlerTest method openDocument.

private void openDocument(ICompilationUnit cu, String content, int version) {
    DidOpenTextDocumentParams openParms = new DidOpenTextDocumentParams();
    TextDocumentItem textDocument = new TextDocumentItem();
    textDocument.setLanguageId("java");
    textDocument.setText(content);
    textDocument.setUri(JDTUtils.toURI(cu));
    textDocument.setVersion(version);
    openParms.setTextDocument(textDocument);
    lifeCycleHandler.didOpen(openParms);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams)

Example 5 with DidOpenTextDocumentParams

use of org.eclipse.lsp4j.DidOpenTextDocumentParams in project xtext-core by eclipse.

the class UnknownProjectConfigTest method testCompletionWithInmemoryScheme_01.

@Test
public void testCompletionWithInmemoryScheme_01() throws Exception {
    initialize(it -> it.setWorkspaceFolders(Lists.newArrayList()));
    String inmemoryUri = "inmemory:/mydoc.testlang";
    languageServer.didOpen(new DidOpenTextDocumentParams(newTextDocumentItem(inmemoryUri, "type Foo {}")));
    checkCompletion(inmemoryUri);
}
Also used : DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Test(org.junit.Test)

Aggregations

DidOpenTextDocumentParams (org.eclipse.lsp4j.DidOpenTextDocumentParams)16 TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)11 Test (org.junit.Test)10 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Gson (com.google.gson.Gson)1 File (java.io.File)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 BallerinaLanguageServer (org.ballerinalang.langserver.BallerinaLanguageServer)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)1 Endpoint (org.eclipse.lsp4j.jsonrpc.Endpoint)1 ResponseError (org.eclipse.lsp4j.jsonrpc.messages.ResponseError)1 ResponseMessage (org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage)1 ServiceEndpoints (org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints)1 TestLangLSPExtension (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension)1 TextOfLineParam (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineParam)1 TextOfLineResult (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineResult)1