Search in sources :

Example 6 with Configuration

use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.

the class ServerContextTest method testConfigurationMetadata.

@Test
void testConfigurationMetadata() {
    Path path = Absolute.path(PATH_TO_METADATA);
    serverContext.setConfigurationRoot(path);
    Configuration configurationMetadata = serverContext.getConfiguration();
    assertThat(configurationMetadata).isNotNull();
    assertThat(configurationMetadata.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
    assertThat(configurationMetadata.getConfigurationSource()).isEqualTo(ConfigurationSource.DESIGNER);
    assertThat(configurationMetadata.getCompatibilityMode().getMinor()).isEqualTo(3);
    assertThat(configurationMetadata.getCompatibilityMode().getVersion()).isEqualTo(10);
    File file = new File(PATH_TO_METADATA, PATH_TO_MODULE_FILE);
    ModuleType type = configurationMetadata.getModuleType(Absolute.uri(file.toURI()));
    assertThat(type).isEqualTo(ModuleType.CommonModule);
}
Also used : Path(java.nio.file.Path) ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType) Configuration(com.github._1c_syntax.mdclasses.Configuration) File(java.io.File) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with Configuration

use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.

the class CachedPublicDiagnosticTest method getDocumentContextFromFile.

@SneakyThrows
void getDocumentContextFromFile(Path testFile) {
    Path path = Absolute.path(PATH_TO_METADATA);
    Path moduleFile = 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(moduleFile.toUri()));
}
Also used : Path(java.nio.file.Path) MDCommonModule(com.github._1c_syntax.mdclasses.mdo.MDCommonModule) SneakyThrows(lombok.SneakyThrows)

Example 8 with Configuration

use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.

the class CommonModuleInvalidTypeDiagnosticTest 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 9 with Configuration

use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.

the class CommonModuleNameCachedDiagnosticTest 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 10 with Configuration

use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.

the class CommonModuleNameClientServerDiagnosticTest 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)

Aggregations

Path (java.nio.file.Path)20 Test (org.junit.jupiter.api.Test)17 Configuration (com.github._1c_syntax.mdclasses.Configuration)14 File (java.io.File)12 MDCommonModule (com.github._1c_syntax.mdclasses.mdo.MDCommonModule)10 SneakyThrows (lombok.SneakyThrows)10 CompatibilityMode (com.github._1c_syntax.mdclasses.common.CompatibilityMode)9 Collectors (java.util.stream.Collectors)8 ModuleType (com.github._1c_syntax.mdclasses.mdo.support.ModuleType)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 ConfigurationExtension (com.github._1c_syntax.mdclasses.ConfigurationExtension)6 MDOType (com.github._1c_syntax.mdclasses.mdo.support.MDOType)6 ScriptVariant (com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant)6 Absolute (com.github._1c_syntax.utils.Absolute)6 Set (java.util.Set)6 ConfigurationSource (com.github._1c_syntax.mdclasses.common.ConfigurationSource)5 AbstractMDOForm (com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm)5 AbstractMDObjectBase (com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase)5 MDCommonForm (com.github._1c_syntax.mdclasses.mdo.MDCommonForm)5 Form (com.github._1c_syntax.mdclasses.mdo.children.Form)5