use of com.github._1c_syntax.mdclasses.Configuration in project mdclasses by 1c-syntax.
the class ConfigurationTest method testOrdinaryMode.
@Test
void testOrdinaryMode() {
File srcPath = new File("src/test/resources/metadata/original_ordinary");
Configuration configuration = Configuration.create(srcPath.toPath());
assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.ORDINARY_APPLICATION);
}
use of com.github._1c_syntax.mdclasses.Configuration in project mdclasses by 1c-syntax.
the class ConfigurationTest method testDesigner.
@Test
void testDesigner() {
File srcPath = new File("src/test/resources/metadata/original");
Configuration configuration = Configuration.create(srcPath.toPath());
assertThat(configuration).isNotInstanceOf(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.DONT_USE);
assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
assertThat(configuration.isUseManagedFormInOrdinaryApplication()).isTrue();
assertThat(configuration.isUseOrdinaryFormInManagedApplication()).isFalse();
assertThat(configuration.getModulesByType()).hasSize(18);
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.getModulesBySupport()).isEmpty();
assertThat(configuration.getModulesByObject()).hasSize(18);
assertThat(configuration.getModules()).hasSize(18);
assertThat(configuration.getCommonModules()).hasSize(6);
assertThat(configuration.getLanguages()).hasSize(3);
assertThat(configuration.getRoles()).hasSize(1);
assertThat(configuration.getChildren()).hasSize(112);
checkChildCount(configuration, MDOType.CONFIGURATION, 1);
checkChildCount(configuration, MDOType.COMMAND, 1);
checkChildCount(configuration, MDOType.FORM, 8);
checkChildCount(configuration, MDOType.TEMPLATE, 2);
checkChildCount(configuration, MDOType.ATTRIBUTE, 34);
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.INTERFACE, 1);
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, 1);
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(111);
assertThat(configuration.getCommonModule("ГлобальныйОбщийМодуль")).isPresent();
assertThat(configuration.getCommonModule("ГлобальныйОбщийМодуль3")).isNotPresent();
checkFillPath(configuration.getChildren());
checkFormData(configuration.getChildren());
var modulesByType = configuration.getModulesByMDORef("CommonModule.ГлобальныйОбщийМодуль");
assertThat(modulesByType).hasSize(1).containsKey(ModuleType.CommonModule);
modulesByType = configuration.getModulesByMDORef("WSReference.WSСсылка");
assertThat(modulesByType).isEmpty();
modulesByType = configuration.getModulesByMDORef(configuration.getCommonModule("ГлобальныйОбщийМодуль").get().getMdoReference());
assertThat(modulesByType).hasSize(1).containsKey(ModuleType.CommonModule);
}
use of com.github._1c_syntax.mdclasses.Configuration in project mdclasses by 1c-syntax.
the class MDConfigurationTest method testEDT.
@Override
@Test
void testEDT() {
var mdo = getMDObjectEDT("Configuration/Configuration.mdo");
checkBaseField(mdo, MDConfiguration.class, "Конфигурация", "46c7c1d0-b04d-4295-9b04-ae3207c18d29");
checkNoChildren(mdo);
checkModules(((AbstractMDObjectBSL) mdo).getModules(), 3, "Configuration", ModuleType.SessionModule, ModuleType.ExternalConnectionModule, ModuleType.ManagedApplicationModule);
var configuration = (MDConfiguration) mdo;
assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC);
assertThat(configuration.getDefaultLanguage().isRight()).isTrue();
assertThat(configuration.getDefaultLanguage().get().getName()).isEqualTo("Русский");
assertThat(configuration.getDefaultRunMode()).isEqualTo("ManagedApplication");
assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.USE);
assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE_WITH_WARNINGS);
assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
assertThat(configuration.getConfigurationExtensionPurpose()).isEqualTo(ConfigurationExtensionPurpose.PATCH);
assertThat(configuration.getObjectBelonging()).isEqualTo(ObjectBelonging.OWN);
assertThat(configuration.getNamePrefix()).isEmpty();
assertThat(configuration.getChildren()).hasSize(61).allMatch(Either::isRight);
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);
checkSubsystems(configuration, 5);
checkCommonAttributes(configuration);
}
use of com.github._1c_syntax.mdclasses.Configuration in project sonar-bsl-plugin-community by 1c-syntax.
the class BSLCoreSensor method getLanguageServerConfiguration.
private LanguageServerConfiguration getLanguageServerConfiguration() {
boolean overrideConfiguration = context.config().get(BSLCommunityProperties.LANG_SERVER_OVERRIDE_CONFIGURATION_KEY).map(Boolean::parseBoolean).orElse(BSLCommunityProperties.LANG_SERVER_OVERRIDE_CONFIGURATION_DEFAULT_VALUE);
var configuration = BSLLSBinding.getLanguageServerConfiguration();
if (overrideConfiguration) {
String configurationPath = context.config().get(BSLCommunityProperties.LANG_SERVER_CONFIGURATION_PATH_KEY).orElse(BSLCommunityProperties.LANG_SERVER_CONFIGURATION_PATH_DEFAULT_VALUE);
File configurationFile = new File(configurationPath);
if (configurationFile.exists()) {
LOGGER.info("BSL LS configuration file exists. Overriding SonarQube rules' settings...");
configuration.update(configurationFile);
return configuration;
} else {
LOGGER.error("Can't find bsl configuration file {}. Using SonarQube config instead.", configurationPath);
}
}
String diagnosticLanguageCode = context.config().get(BSLCommunityProperties.LANG_SERVER_DIAGNOSTIC_LANGUAGE_KEY).orElse(BSLCommunityProperties.LANG_SERVER_DIAGNOSTIC_LANGUAGE_DEFAULT_VALUE);
configuration.setLanguage(Language.valueOf(diagnosticLanguageCode.toUpperCase(Locale.ENGLISH)));
SkipSupport skipSupport = context.config().get(BSLCommunityProperties.LANG_SERVER_COMPUTE_DIAGNOSTICS_SKIP_SUPPORT_KEY).map(value -> value.toUpperCase(Locale.ENGLISH).replace(" ", "_")).map(SkipSupport::valueOf).orElse(SkipSupport.valueOf(BSLCommunityProperties.LANG_SERVER_COMPUTE_DIAGNOSTICS_SKIP_SUPPORT_DEFAULT_VALUE.toUpperCase(Locale.ENGLISH)));
configuration.getDiagnosticsOptions().setSkipSupport(skipSupport);
ActiveRules activeRules = context.activeRules();
Map<String, Either<Boolean, Map<String, Object>>> diagnostics = new HashMap<>();
Collection<DiagnosticInfo> diagnosticInfos = BSLLSBinding.getDiagnosticInfos();
for (DiagnosticInfo diagnosticInfo : diagnosticInfos) {
String diagnosticCode = diagnosticInfo.getCode().getStringValue();
ActiveRule activeRule = activeRules.find(RuleKey.of(BSLLanguageServerRuleDefinition.REPOSITORY_KEY, diagnosticCode));
if (activeRule == null) {
diagnostics.put(diagnosticCode, Either.forLeft(false));
} else {
Map<String, String> params = activeRule.params();
List<DiagnosticParameterInfo> diagnosticParameters = diagnosticInfo.getParameters();
Map<String, Object> diagnosticConfiguration = new HashMap<>(diagnosticParameters.size());
params.forEach((String key, String value) -> diagnosticInfo.getParameter(key).ifPresent(diagnosticParameterInfo -> diagnosticConfiguration.put(key, castDiagnosticParameterValue(value, diagnosticParameterInfo.getType()))));
diagnostics.put(diagnosticCode, Either.forRight(diagnosticConfiguration));
}
}
configuration.getDiagnosticsOptions().setParameters(diagnostics);
return configuration;
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class AnalyzeCommand method call.
public Integer call() {
Path workspaceDir = Absolute.path(workspaceDirOption);
if (!workspaceDir.toFile().exists()) {
LOGGER.error("Workspace dir `{}` is not exists", workspaceDir);
return 1;
}
Path srcDir = Absolute.path(srcDirOption);
if (!srcDir.toFile().exists()) {
LOGGER.error("Source dir `{}` is not exists", srcDir);
return 1;
}
File configurationFile = new File(configurationOption);
configuration.update(configurationFile);
Path configurationPath = LanguageServerConfiguration.getCustomConfigurationRoot(configuration, srcDir);
context.setConfigurationRoot(configurationPath);
Collection<File> files = FileUtils.listFiles(srcDir.toFile(), new String[] { "bsl", "os" }, true);
context.populateContext(files);
List<FileInfo> fileInfos;
if (silentMode) {
fileInfos = files.parallelStream().map((File file) -> getFileInfoFromFile(workspaceDir, file)).collect(Collectors.toList());
} else {
try (ProgressBar pb = new ProgressBarBuilder().setTaskName("Analyzing files...").setInitialMax(files.size()).setStyle(ProgressBarStyle.ASCII).build()) {
fileInfos = files.parallelStream().map((File file) -> {
pb.step();
return getFileInfoFromFile(workspaceDir, file);
}).collect(Collectors.toList());
}
}
AnalysisInfo analysisInfo = new AnalysisInfo(LocalDateTime.now(), fileInfos, srcDir.toString());
Path outputDir = Absolute.path(outputDirOption);
aggregator.report(analysisInfo, outputDir);
return 0;
}
Aggregations