Search in sources :

Example 26 with Diagnostics

use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.

the class TimeoutsInExternalResourcesDiagnosticTest method testCompatibilityMode837.

@SneakyThrows
@Test
void testCompatibilityMode837() {
    // when
    FileUtils.writeStringToFile(Paths.get(tempDir.toAbsolutePath().toString(), "Configuration.xml").toFile(), FileUtils.readFileToString(CONFIGURATION_FILE_PATH, StandardCharsets.UTF_8).replace("Version8_3_10", "Version8_3_7"), StandardCharsets.UTF_8);
    Path testFile = Paths.get("./src/test/resources/diagnostics/TimeoutsInExternalResourcesDiagnostic837.bsl").toAbsolutePath();
    initServerContext(tempDir.toAbsolutePath());
    DocumentContext newDocumentContext = TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context);
    List<Diagnostic> diagnostics = getDiagnostics(newDocumentContext);
    // then
    assertThat(newDocumentContext.getServerContext().getConfiguration().getCompatibilityMode()).isNotNull();
    assertThat(CompatibilityMode.compareTo(newDocumentContext.getServerContext().getConfiguration().getCompatibilityMode(), DiagnosticCompatibilityMode.COMPATIBILITY_MODE_8_3_7.getCompatibilityMode())).isZero();
    assertThat(diagnostics).hasSize(9);
    // check ranges
    assertThat(diagnostics, true).hasRange(3, 20, 3, 75).hasRange(5, 20, 5, 92).hasRange(9, 18, 9, 72).hasRange(13, 16, 13, 80).hasRange(21, 21, 21, 65).hasRange(34, 14, 34, 43).hasRange(71, 26, 71, 114).hasRange(78, 10, 78, 39).hasRange(80, 47, 80, 76);
}
Also used : Path(java.nio.file.Path) Diagnostic(org.eclipse.lsp4j.Diagnostic) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) Test(org.junit.jupiter.api.Test) SneakyThrows(lombok.SneakyThrows)

Example 27 with Diagnostics

use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.

the class UsingSynchronousCallsDiagnosticTest method testUse.

@Test
void testUse() {
    DocumentContext documentContext = getDocumentContextWithUseFlag(UseMode.USE);
    List<Diagnostic> diagnostics = getDiagnostics(documentContext);
    assertThat(diagnostics).isEmpty();
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentContext (com.github._1c_syntax.bsl.languageserver.context.DocumentContext)25 Diagnostic (org.eclipse.lsp4j.Diagnostic)24 Test (org.junit.jupiter.api.Test)19 CodeAction (org.eclipse.lsp4j.CodeAction)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Path (java.nio.file.Path)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 LanguageServerConfiguration (com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration)5 DiagnosticInfo (com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo)5 Collectors (java.util.stream.Collectors)5 SneakyThrows (lombok.SneakyThrows)5 Collections (java.util.Collections)4 Range (org.eclipse.lsp4j.Range)4 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)4 TestUtils (com.github._1c_syntax.bsl.languageserver.util.TestUtils)3 Collection (java.util.Collection)3 Map (java.util.Map)3 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2