Search in sources :

Example 16 with Configuration

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);
}
Also used : Configuration(com.github._1c_syntax.mdclasses.Configuration) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 17 with Configuration

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);
}
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 18 with Configuration

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);
}
Also used : CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) Either(io.vavr.control.Either) Test(org.junit.jupiter.api.Test)

Example 19 with 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;
}
Also used : ActiveRule(org.sonar.api.batch.rule.ActiveRule) Arrays(java.util.Arrays) Language(com.github._1c_syntax.bsl.languageserver.configuration.Language) Token(org.antlr.v4.runtime.Token) ActiveRules(org.sonar.api.batch.rule.ActiveRules) StringUtils(org.apache.commons.lang3.StringUtils) FilePredicates(org.sonar.api.batch.fs.FilePredicates) Absolute(com.github._1c_syntax.utils.Absolute) FileLinesContext(org.sonar.api.measures.FileLinesContext) FileLinesContextFactory(org.sonar.api.measures.FileLinesContextFactory) Loggers(org.sonar.api.utils.log.Loggers) LanguageServerConfiguration(com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration) Locale(java.util.Locale) Map(java.util.Map) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) URI(java.net.URI) MetricStorage(com.github._1c_syntax.bsl.languageserver.context.MetricStorage) Path(java.nio.file.Path) ServerContext(com.github._1c_syntax.bsl.languageserver.context.ServerContext) DiagnosticInfo(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo) Collection(java.util.Collection) FileSystem(org.sonar.api.batch.fs.FileSystem) SensorContext(org.sonar.api.batch.sensor.SensorContext) Collectors(java.util.stream.Collectors) CoreMetrics(org.sonar.api.measures.CoreMetrics) StandardCharsets(java.nio.charset.StandardCharsets) SensorDescriptor(org.sonar.api.batch.sensor.SensorDescriptor) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) RuleKey(org.sonar.api.rule.RuleKey) SkipSupport(com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.SkipSupport) ProgressBarBuilder(me.tongfei.progressbar.ProgressBarBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Sensor(org.sonar.api.batch.sensor.Sensor) HashMap(java.util.HashMap) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) BSLLSBinding(com.github._1c_syntax.bsl.languageserver.BSLLSBinding) BSLLanguage(com.github._1c_syntax.bsl.sonar.language.BSLLanguage) ArrayList(java.util.ArrayList) StreamSupport(java.util.stream.StreamSupport) Logger(org.sonar.api.utils.log.Logger) ProgressBar(me.tongfei.progressbar.ProgressBar) BSLLexer(com.github._1c_syntax.bsl.parser.BSLLexer) IOException(java.io.IOException) File(java.io.File) ProgressBarStyle(me.tongfei.progressbar.ProgressBarStyle) DiagnosticParameterInfo(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameterInfo) BSLLanguageServerRuleDefinition(com.github._1c_syntax.bsl.sonar.language.BSLLanguageServerRuleDefinition) Collections(java.util.Collections) HashMap(java.util.HashMap) DiagnosticInfo(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo) ActiveRule(org.sonar.api.batch.rule.ActiveRule) DiagnosticParameterInfo(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameterInfo) SkipSupport(com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.SkipSupport) ActiveRules(org.sonar.api.batch.rule.ActiveRules) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File)

Example 20 with 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;
}
Also used : Path(java.nio.file.Path) FileInfo(com.github._1c_syntax.bsl.languageserver.reporters.data.FileInfo) ProgressBarBuilder(me.tongfei.progressbar.ProgressBarBuilder) AnalysisInfo(com.github._1c_syntax.bsl.languageserver.reporters.data.AnalysisInfo) File(java.io.File) ProgressBar(me.tongfei.progressbar.ProgressBar)

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