Search in sources :

Example 11 with Configuration

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

the class CommonModuleNameGlobalDiagnosticTest 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 12 with Configuration

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

the class CommonModuleNameServerCallDiagnosticTest 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 13 with Configuration

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

the class GenerateStandardRegionsSupplier method getRegionsLanguage.

private ScriptVariant getRegionsLanguage(DocumentContext documentContext, FileType fileType) {
    ScriptVariant regionsLanguage;
    Configuration configuration = documentContext.getServerContext().getConfiguration();
    if (configuration.getConfigurationSource() == ConfigurationSource.EMPTY || fileType == FileType.OS) {
        regionsLanguage = getScriptVariantFromConfigLanguage();
    } else {
        regionsLanguage = documentContext.getServerContext().getConfiguration().getScriptVariant();
    }
    return regionsLanguage;
}
Also used : Configuration(com.github._1c_syntax.mdclasses.Configuration) LanguageServerConfiguration(com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration) ScriptVariant(com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant)

Example 14 with Configuration

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

the class ConfigurationTest method testDesignerExt2.

@Test
void testDesignerExt2() {
    File srcPath = new File("src/test/resources/metadata/original_ext2");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isInstanceOf(ConfigurationExtension.class);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.DESIGNER);
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC);
    assertThat(configuration.getDefaultLanguage().getName()).isEqualTo("Русский");
    assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.MANAGED_APPLICATION);
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getObjectAutonumerationMode()).isEmpty();
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(((ConfigurationExtension) configuration).getConfigurationExtensionPurpose()).isEqualTo(ConfigurationExtensionPurpose.ADD_ON);
    assertThat(((ConfigurationExtension) configuration).getNamePrefix()).isEqualTo("Расш1_");
    assertThat(configuration.getModulesByType()).hasSize(2);
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModules()).hasSize(2);
    assertThat(configuration.getRoles()).isEmpty();
    assertThat(configuration.getChildren()).hasSize(5);
    checkChildCount(configuration, MDOType.CONFIGURATION, 1);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 2);
    checkChildCount(configuration, MDOType.LANGUAGE, 1);
    checkChildCount(configuration, MDOType.SUBSYSTEM, 1);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(5);
    assertThat(configuration.getCommonModule("ПростойОбщийМодуль")).isPresent();
    assertThat(configuration.getCommonModule("НесуществующийМодуль")).isNotPresent();
    assertThat(configuration.getChildren()).filteredOn(mdObjectBase -> mdObjectBase.getObjectBelonging() == ObjectBelonging.ADOPTED).hasSize(4);
    assertThat(configuration.getChildren()).filteredOn(mdObjectBase -> mdObjectBase.getObjectBelonging() == ObjectBelonging.OWN).hasSize(1);
}
Also used : ConfigurationExtension(com.github._1c_syntax.mdclasses.ConfigurationExtension) ScriptVariant(com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AbstractMDObjectBase(com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase) MDOType(com.github._1c_syntax.mdclasses.mdo.support.MDOType) ConfigurationExtensionPurpose(com.github._1c_syntax.mdclasses.mdo.support.ConfigurationExtensionPurpose) Absolute(com.github._1c_syntax.utils.Absolute) Configuration(com.github._1c_syntax.mdclasses.Configuration) ConfigurationSource(com.github._1c_syntax.mdclasses.common.ConfigurationSource) Form(com.github._1c_syntax.mdclasses.mdo.children.Form) Path(java.nio.file.Path) FormType(com.github._1c_syntax.mdclasses.mdo.support.FormType) DataLockControlMode(com.github._1c_syntax.mdclasses.mdo.support.DataLockControlMode) ApplicationRunMode(com.github._1c_syntax.mdclasses.mdo.support.ApplicationRunMode) AbstractMDOForm(com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm) Set(java.util.Set) ConfigurationExtension(com.github._1c_syntax.mdclasses.ConfigurationExtension) ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType) Collectors(java.util.stream.Collectors) MDCommonForm(com.github._1c_syntax.mdclasses.mdo.MDCommonForm) File(java.io.File) Test(org.junit.jupiter.api.Test) ObjectBelonging(com.github._1c_syntax.mdclasses.mdo.support.ObjectBelonging) Paths(java.nio.file.Paths) UseMode(com.github._1c_syntax.mdclasses.mdo.support.UseMode) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) Configuration(com.github._1c_syntax.mdclasses.Configuration) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 15 with Configuration

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

the class ConfigurationTest method testEDTEn.

@Test
void testEDTEn() {
    File srcPath = new File("src/test/resources/metadata/edt_en");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isNotInstanceOf(ConfigurationExtension.class);
    assertThat(configuration.getName()).isEqualTo("Configuration");
    assertThat(configuration.getUuid()).isEqualTo("04c0322d-92da-49ab-87e5-82c8dcd50888");
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.EDT);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 14))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 14))).isZero();
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.ENGLISH);
    assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.MANAGED_APPLICATION);
    assertThat(configuration.getDefaultLanguage().getName()).isEqualTo("English");
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC_AND_MANAGED);
    assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.getModulesByType()).hasSize(2);
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModulesByObject()).hasSize(2);
    assertThat(configuration.getModules()).hasSize(2);
    assertThat(configuration.getCommonModules()).hasSize(2);
    assertThat(configuration.getLanguages()).hasSize(1);
    assertThat(configuration.getRoles()).isEmpty();
    assertThat(configuration.getChildren()).hasSize(4);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 2);
    checkChildCount(configuration, MDOType.LANGUAGE, 1);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(4);
    assertThat(configuration.getCommonModule("CommonModule")).isPresent();
    assertThat(configuration.getCommonModule("CommonModule3")).isNotPresent();
}
Also used : Configuration(com.github._1c_syntax.mdclasses.Configuration) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) File(java.io.File) Test(org.junit.jupiter.api.Test)

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