Search in sources :

Example 26 with Configuration

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

the class AbstractMultilingualStringDiagnostic method configure.

@Override
public void configure(Map<String, Object> configuration) {
    declaredLanguages = (String) configuration.get("declaredLanguages");
    parser = new MultilingualStringAnalyser(declaredLanguages);
}
Also used : MultilingualStringAnalyser(com.github._1c_syntax.bsl.languageserver.utils.MultilingualStringAnalyser)

Example 27 with Configuration

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

the class CommonModuleAssignDiagnostic method visitLValue.

@Override
public ParseTree visitLValue(BSLParser.LValueContext ctx) {
    TerminalNode identifier = ctx.IDENTIFIER();
    if (identifier == null || ctx.acceptor() != null) {
        return ctx;
    }
    Configuration configuration = documentContext.getServerContext().getConfiguration();
    if (configuration.getCommonModule(identifier.getText()).isPresent()) {
        diagnosticStorage.addDiagnostic(identifier, info.getMessage(identifier.getText()));
    }
    return ctx;
}
Also used : Configuration(com.github._1c_syntax.mdclasses.Configuration) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode)

Example 28 with Configuration

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

the class ConfigurationTest method testDesignerExt.

@Test
void testDesignerExt() {
    File srcPath = new File("src/test/resources/metadata/original_ext");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isInstanceOf(ConfigurationExtension.class);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 16))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 16))).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.CUSTOMIZATION);
    assertThat(((ConfigurationExtension) configuration).getNamePrefix()).isEqualTo("Расш_");
    assertThat(configuration.getModulesByType()).hasSize(9);
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModules()).hasSize(9);
    assertThat(configuration.getRoles()).hasSize(2);
    assertThat(configuration.getChildren()).hasSize(142);
    checkChildCount(configuration, MDOType.CONFIGURATION, 1);
    checkChildCount(configuration, MDOType.COMMAND, 2);
    checkChildCount(configuration, MDOType.FORM, 12);
    checkChildCount(configuration, MDOType.TEMPLATE, 2);
    checkChildCount(configuration, MDOType.ATTRIBUTE, 41);
    checkChildCount(configuration, MDOType.ACCOUNTING_REGISTER, 2);
    checkChildCount(configuration, MDOType.ACCUMULATION_REGISTER, 2);
    checkChildCount(configuration, MDOType.BUSINESS_PROCESS, 1);
    checkChildCount(configuration, MDOType.CALCULATION_REGISTER, 2);
    checkChildCount(configuration, MDOType.CATALOG, 2);
    checkChildCount(configuration, MDOType.CHART_OF_ACCOUNTS, 2);
    checkChildCount(configuration, MDOType.CHART_OF_CALCULATION_TYPES, 2);
    checkChildCount(configuration, MDOType.CHART_OF_CHARACTERISTIC_TYPES, 2);
    checkChildCount(configuration, MDOType.COMMAND_GROUP, 2);
    checkChildCount(configuration, MDOType.COMMON_ATTRIBUTE, 1);
    checkChildCount(configuration, MDOType.COMMON_COMMAND, 2);
    checkChildCount(configuration, MDOType.COMMON_FORM, 2);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 9);
    checkChildCount(configuration, MDOType.COMMON_PICTURE, 2);
    checkChildCount(configuration, MDOType.COMMON_TEMPLATE, 2);
    checkChildCount(configuration, MDOType.CONSTANT, 2);
    checkChildCount(configuration, MDOType.DATA_PROCESSOR, 2);
    checkChildCount(configuration, MDOType.DEFINED_TYPE, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_JOURNAL, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_NUMERATOR, 1);
    checkChildCount(configuration, MDOType.DOCUMENT, 2);
    checkChildCount(configuration, MDOType.ENUM, 2);
    checkChildCount(configuration, MDOType.EVENT_SUBSCRIPTION, 1);
    checkChildCount(configuration, MDOType.EXCHANGE_PLAN, 2);
    checkChildCount(configuration, MDOType.FILTER_CRITERION, 2);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTION, 2);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTIONS_PARAMETER, 2);
    checkChildCount(configuration, MDOType.HTTP_SERVICE, 2);
    checkChildCount(configuration, MDOType.INFORMATION_REGISTER, 4);
    checkChildCount(configuration, MDOType.INTERFACE, 0);
    checkChildCount(configuration, MDOType.LANGUAGE, 1);
    checkChildCount(configuration, MDOType.REPORT, 2);
    checkChildCount(configuration, MDOType.ROLE, 2);
    checkChildCount(configuration, MDOType.SCHEDULED_JOB, 1);
    checkChildCount(configuration, MDOType.SEQUENCE, 1);
    checkChildCount(configuration, MDOType.SESSION_PARAMETER, 2);
    checkChildCount(configuration, MDOType.SETTINGS_STORAGE, 1);
    checkChildCount(configuration, MDOType.STYLE_ITEM, 2);
    checkChildCount(configuration, MDOType.STYLE, 2);
    checkChildCount(configuration, MDOType.SUBSYSTEM, 2);
    checkChildCount(configuration, MDOType.TASK, 1);
    checkChildCount(configuration, MDOType.WEB_SERVICE, 2);
    checkChildCount(configuration, MDOType.WS_REFERENCE, 2);
    checkChildCount(configuration, MDOType.XDTO_PACKAGE, 2);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(142);
    assertThat(configuration.getCommonModule("ПростойОбщийМодуль")).isPresent();
    assertThat(configuration.getCommonModule("НесуществующийМодуль")).isNotPresent();
    assertThat(configuration.getChildren()).filteredOn(mdObjectBase -> mdObjectBase.getObjectBelonging() == ObjectBelonging.ADOPTED).hasSize(78);
    assertThat(configuration.getChildren()).filteredOn(mdObjectBase -> mdObjectBase.getObjectBelonging() == ObjectBelonging.OWN).hasSize(64);
}
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 29 with Configuration

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

the class ConfigurationTest method testEDT.

@Test
void testEDT() {
    File srcPath = new File("src/test/resources/metadata/edt");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isNotInstanceOf(ConfigurationExtension.class);
    assertThat(configuration.getName()).isEqualTo("Конфигурация");
    assertThat(configuration.getUuid()).isEqualTo("46c7c1d0-b04d-4295-9b04-ae3207c18d29");
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.EDT);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
    assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.MANAGED_APPLICATION);
    assertThat(configuration.getDefaultLanguage().getName()).isEqualTo("Русский");
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC);
    assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE_WITH_WARNINGS);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.isUseManagedFormInOrdinaryApplication()).isTrue();
    assertThat(configuration.isUseOrdinaryFormInManagedApplication()).isTrue();
    assertThat(configuration.getCopyrights()).hasSize(2).anyMatch(copyright -> copyright.getContent().equals("Моя Программа") && copyright.getLanguage().equals("ru")).anyMatch(copyright -> copyright.getContent().equals("My program") && copyright.getLanguage().equals("en"));
    assertThat(configuration.getBriefInformation()).hasSize(2).anyMatch(briefInfo -> briefInfo.getLanguage().equals("ru") && briefInfo.getContent().equals("Краткая информация")).anyMatch(briefInfo -> briefInfo.getLanguage().equals("en") && briefInfo.getContent().equals("Short info"));
    assertThat(configuration.getDetailedInformation()).hasSize(2).anyMatch(briefInfo -> briefInfo.getLanguage().equals("ru") && briefInfo.getContent().equals("Подробная информация")).anyMatch(briefInfo -> briefInfo.getLanguage().equals("en") && briefInfo.getContent().equals("Detailed info"));
    assertThat(configuration.getModulesByType()).hasSize(38);
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModulesByObject()).hasSize(38);
    assertThat(configuration.getModules()).hasSize(38);
    assertThat(configuration.getCommonModules()).hasSize(6);
    assertThat(configuration.getLanguages()).hasSize(3);
    assertThat(configuration.getRoles()).hasSize(1);
    assertThat(configuration.getChildren()).hasSize(106);
    checkChildCount(configuration, MDOType.CONFIGURATION, 1);
    checkChildCount(configuration, MDOType.COMMAND, 3);
    checkChildCount(configuration, MDOType.FORM, 7);
    checkChildCount(configuration, MDOType.TEMPLATE, 2);
    checkChildCount(configuration, MDOType.ATTRIBUTE, 27);
    checkChildCount(configuration, MDOType.WS_OPERATION, 2);
    checkChildCount(configuration, MDOType.HTTP_SERVICE_URL_TEMPLATE, 1);
    checkChildCount(configuration, MDOType.HTTP_SERVICE_METHOD, 2);
    checkChildCount(configuration, MDOType.ACCOUNTING_REGISTER, 1);
    checkChildCount(configuration, MDOType.ACCUMULATION_REGISTER, 1);
    checkChildCount(configuration, MDOType.BUSINESS_PROCESS, 1);
    checkChildCount(configuration, MDOType.CALCULATION_REGISTER, 1);
    checkChildCount(configuration, MDOType.CATALOG, 1);
    checkChildCount(configuration, MDOType.CHART_OF_ACCOUNTS, 1);
    checkChildCount(configuration, MDOType.CHART_OF_CALCULATION_TYPES, 1);
    checkChildCount(configuration, MDOType.CHART_OF_CHARACTERISTIC_TYPES, 1);
    checkChildCount(configuration, MDOType.COMMAND_GROUP, 1);
    checkChildCount(configuration, MDOType.COMMON_ATTRIBUTE, 1);
    checkChildCount(configuration, MDOType.COMMON_COMMAND, 1);
    checkChildCount(configuration, MDOType.COMMON_FORM, 1);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 6);
    checkChildCount(configuration, MDOType.COMMON_PICTURE, 1);
    checkChildCount(configuration, MDOType.COMMON_TEMPLATE, 10);
    checkChildCount(configuration, MDOType.CONSTANT, 1);
    checkChildCount(configuration, MDOType.DATA_PROCESSOR, 1);
    checkChildCount(configuration, MDOType.DEFINED_TYPE, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_JOURNAL, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_NUMERATOR, 1);
    checkChildCount(configuration, MDOType.DOCUMENT, 1);
    checkChildCount(configuration, MDOType.ENUM, 1);
    checkChildCount(configuration, MDOType.EVENT_SUBSCRIPTION, 1);
    checkChildCount(configuration, MDOType.EXCHANGE_PLAN, 1);
    checkChildCount(configuration, MDOType.FILTER_CRITERION, 1);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTION, 1);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTIONS_PARAMETER, 1);
    checkChildCount(configuration, MDOType.HTTP_SERVICE, 1);
    checkChildCount(configuration, MDOType.INFORMATION_REGISTER, 2);
    checkChildCount(configuration, MDOType.LANGUAGE, 3);
    checkChildCount(configuration, MDOType.REPORT, 1);
    checkChildCount(configuration, MDOType.ROLE, 1);
    checkChildCount(configuration, MDOType.SCHEDULED_JOB, 1);
    checkChildCount(configuration, MDOType.SEQUENCE, 1);
    checkChildCount(configuration, MDOType.SESSION_PARAMETER, 1);
    checkChildCount(configuration, MDOType.SETTINGS_STORAGE, 1);
    checkChildCount(configuration, MDOType.STYLE_ITEM, 1);
    checkChildCount(configuration, MDOType.STYLE, 1);
    checkChildCount(configuration, MDOType.SUBSYSTEM, 2);
    checkChildCount(configuration, MDOType.TASK, 1);
    checkChildCount(configuration, MDOType.WEB_SERVICE, 1);
    checkChildCount(configuration, MDOType.WS_REFERENCE, 1);
    checkChildCount(configuration, MDOType.XDTO_PACKAGE, 1);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(105);
    assertThat(configuration.getCommonModule("ГлобальныйОбщийМодуль")).isPresent();
    assertThat(configuration.getCommonModule("НесуществующийМодуль")).isNotPresent();
    checkFillPath(configuration.getChildren());
    checkFormData(configuration.getChildren());
    var modulesByType = configuration.getModulesByMDORef("Document.ДОкумент1");
    assertThat(modulesByType).hasSize(2).containsKey(ModuleType.ManagerModule).containsKey(ModuleType.ObjectModule);
    modulesByType = configuration.getModulesByMDORef("WSReference.WSСсылка");
    assertThat(modulesByType).isEmpty();
}
Also used : 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 30 with Configuration

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

the class ConfigurationTest method testEmpty.

@Test
void testEmpty() {
    Configuration configuration = Configuration.create(null);
    assertThat(configuration).isNotNull();
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.EMPTY);
    assertThat(configuration.getRootPath()).isNotPresent();
    File file = new File("src/test/resources/metadata/edt/src/Constants/Константа1/ManagerModule.bsl");
    assertThat(configuration.getModuleType(Absolute.uri(file))).isEqualTo(ModuleType.UNKNOWN);
    Configuration configuration2 = Configuration.create();
    assertThat(configuration2).isNotNull();
    assertThat(configuration2.getConfigurationSource()).isEqualTo(ConfigurationSource.EMPTY);
    assertThat(configuration2.getChildren()).isEmpty();
    assertThat(configuration2.getRoles()).isEmpty();
    Configuration configuration3 = Configuration.createExtension();
    assertThat(configuration3).isNotNull();
    assertThat(configuration3.getConfigurationSource()).isEqualTo(ConfigurationSource.EMPTY);
    assertThat(configuration3.getChildren()).isEmpty();
    assertThat(configuration3.getRoles()).isEmpty();
    assertThat(((ConfigurationExtension) configuration3).getConfigurationExtensionPurpose()).isEqualTo(ConfigurationExtensionPurpose.UNDEFINED);
}
Also used : ConfigurationExtension(com.github._1c_syntax.mdclasses.ConfigurationExtension) Configuration(com.github._1c_syntax.mdclasses.Configuration) 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