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);
}
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;
}
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);
}
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();
}
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);
}
Aggregations