Search in sources :

Example 71 with DocumentContext

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

the class QueryComputerTest method compute.

@Test
void compute() {
    // given
    DocumentContext documentContext = TestUtils.getDocumentContextFromFile("./src/test/resources/context/computer/QueryComputerTest.bsl");
    // when
    var queries = documentContext.getQueries();
    // then
    assertThat(queries).hasSize(10);
    assertThat(queries.get(0).getTokens().get(1).getLine()).isEqualTo(3);
    assertThat(queries.get(6).getTokens().get(2).getLine()).isEqualTo(30);
    assertThat(queries.get(8).getTokens().get(1).getLine()).isEqualTo(45);
    assertThat(queries.get(8).getTokens().get(31).getLine()).isEqualTo(50);
    assertThat(queries.get(9).getTokens().get(9).getLine()).isEqualTo(59);
}
Also used : DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 72 with DocumentContext

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

the class CommonModuleNameFullAccessDiagnosticTest method getDocumentContextFromFile.

@SneakyThrows
void getDocumentContextFromFile() {
    Path path = Absolute.path(PATH_TO_METADATA);
    Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
    initServerContext(path);
    var configuration = context.getConfiguration();
    documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
    module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
Also used : Path(java.nio.file.Path) MDCommonModule(com.github._1c_syntax.mdclasses.mdo.MDCommonModule) SneakyThrows(lombok.SneakyThrows)

Example 73 with DocumentContext

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

the class CommonModuleNameGlobalClientDiagnosticTest method getDocumentContextFromFile.

@SneakyThrows
void getDocumentContextFromFile() {
    Path path = Absolute.path(PATH_TO_METADATA);
    Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
    initServerContext(path);
    var configuration = context.getConfiguration();
    documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
    module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
Also used : Path(java.nio.file.Path) MDCommonModule(com.github._1c_syntax.mdclasses.mdo.MDCommonModule) SneakyThrows(lombok.SneakyThrows)

Example 74 with DocumentContext

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

the class CommonModuleNameWordsDiagnosticTest method getDocumentContextFromFile.

@SneakyThrows
void getDocumentContextFromFile() {
    Path path = Absolute.path(PATH_TO_METADATA);
    Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
    initServerContext(path);
    var configuration = context.getConfiguration();
    documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
    module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
Also used : Path(java.nio.file.Path) MDCommonModule(com.github._1c_syntax.mdclasses.mdo.MDCommonModule) SneakyThrows(lombok.SneakyThrows)

Example 75 with DocumentContext

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

the class CompilationDirectiveLostDiagnosticTest method testFormModule.

@Test
void testFormModule() {
    DocumentContext documentContext = getDocumentContext();
    List<Diagnostic> diagnostics = getDiagnostics(documentContext);
    assertThat(diagnostics).hasSize(1);
    assertThat(diagnostics, true).hasRange(9, 8, 9, 16);
}
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)86 Test (org.junit.jupiter.api.Test)69 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)57 Diagnostic (org.eclipse.lsp4j.Diagnostic)36 List (java.util.List)22 Position (org.eclipse.lsp4j.Position)21 SneakyThrows (lombok.SneakyThrows)17 Path (java.nio.file.Path)16 CodeAction (org.eclipse.lsp4j.CodeAction)16 TestUtils (com.github._1c_syntax.bsl.languageserver.util.TestUtils)15 Autowired (org.springframework.beans.factory.annotation.Autowired)15 Collectors (java.util.stream.Collectors)14 Range (org.eclipse.lsp4j.Range)13 ArrayList (java.util.ArrayList)12 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)12 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)12 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)12 LanguageServerConfiguration (com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration)11 MethodSymbol (com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol)10 MDCommonModule (com.github._1c_syntax.mdclasses.mdo.MDCommonModule)10