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));
}
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));
}
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));
}
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);
}
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);
}
Aggregations