From a2c78338127609e967f7cea2d59dd23a4f356519 Mon Sep 17 00:00:00 2001 From: mikrise2 Date: Mon, 16 Oct 2023 16:01:09 +0200 Subject: [PATCH] [ML4SE-158] refactored buildBaseConfig --- .../config/MainTaskTrackerConfig.kt | 18 +++++++++--------- .../tasktracker/config/ide/MainIdeConfig.kt | 2 -- .../tasktracker/config/util/ConfigUtil.kt | 9 +++------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt index 81c1bea2..befe875b 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt @@ -67,55 +67,55 @@ data class MainTaskTrackerConfig( when { fileName.startsWith(CodeTrackingConfig.CONFIG_FILE_PREFIX) -> { mainConfig.codeTrackingConfig = buildBaseConfig( - mainConfig.codeTrackingConfig, configFile, CodeTrackingConfig::buildConfig, logger + configFile, CodeTrackingConfig::buildConfig, logger ) } fileName.startsWith(ActivityTrackingConfig.CONFIG_FILE_PREFIX) -> { mainConfig.activityTrackingConfig = buildBaseConfig( - mainConfig.activityTrackingConfig, configFile, ActivityTrackingConfig::buildConfig, logger + configFile, ActivityTrackingConfig::buildConfig, logger ) } fileName.startsWith(TaskContentConfig.CONFIG_FILE_PREFIX) -> { mainConfig.taskContentConfig = buildBaseConfig( - mainConfig.taskContentConfig, configFile, TaskContentConfig::buildConfig, logger + configFile, TaskContentConfig::buildConfig, logger ) } fileName.startsWith(ScenarioConfig.CONFIG_FILE_PREFIX) -> { mainConfig.scenarioConfig = buildBaseConfig( - mainConfig.scenarioConfig, configFile, ScenarioConfig::buildConfig, logger + configFile, ScenarioConfig::buildConfig, logger ) } fileName.startsWith(WebCamTrackingConfig.CONFIG_FILE_PREFIX) -> { mainConfig.webCamConfig = buildBaseConfig( - mainConfig.webCamConfig, configFile, WebCamTrackingConfig::buildConfig, logger + configFile, WebCamTrackingConfig::buildConfig, logger ) } fileName.startsWith(MainPageContentConfig.CONFIG_FILE_PREFIX) -> { mainConfig.mainPageConfig = buildBaseConfig( - mainConfig.mainPageConfig, configFile, MainPageContentConfig::buildConfig, logger + configFile, MainPageContentConfig::buildConfig, logger ) } fileName.startsWith(FinalPageContentConfig.CONFIG_FILE_PREFIX) -> { mainConfig.finalPageConfig = buildBaseConfig( - mainConfig.finalPageConfig, configFile, FinalPageContentConfig::buildConfig, logger + configFile, FinalPageContentConfig::buildConfig, logger ) } fileName.startsWith(ServerErrorPageConfig.CONFIG_FILE_PREFIX) -> { mainConfig.serverErrorPageConfig = buildBaseConfig( - mainConfig.serverErrorPageConfig, configFile, ServerErrorPageConfig::buildConfig, logger + configFile, ServerErrorPageConfig::buildConfig, logger ) } fileName.startsWith(SurveyConfig.CONFIG_FILE_PREFIX) -> { mainConfig.surveyConfig = buildBaseConfig( - mainConfig.surveyConfig, configFile, SurveyConfig::buildConfig, logger + configFile, SurveyConfig::buildConfig, logger ) } } diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/ide/MainIdeConfig.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/ide/MainIdeConfig.kt index 54c50647..cb2064b2 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/ide/MainIdeConfig.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/ide/MainIdeConfig.kt @@ -26,7 +26,6 @@ class MainIdeConfig : BaseConfig { when { configFile.name.startsWith(InspectionConfig.CONFIG_FILE_PREFIX) -> { mainIdeConfig.inspectionConfig = buildBaseConfig( - mainIdeConfig.inspectionConfig, configFile, InspectionConfig::buildConfig, logger @@ -35,7 +34,6 @@ class MainIdeConfig : BaseConfig { configFile.name.startsWith(SettingsConfig.CONFIG_FILE_PREFIX) -> { mainIdeConfig.settingsConfig = buildBaseConfig( - mainIdeConfig.settingsConfig, configFile, SettingsConfig::buildConfig, logger diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/util/ConfigUtil.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/util/ConfigUtil.kt index 0f35f2b0..bae074b6 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/util/ConfigUtil.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/util/ConfigUtil.kt @@ -5,14 +5,11 @@ import org.jetbrains.research.tasktracker.config.BaseConfig import java.io.File inline fun buildBaseConfig( - config: T?, configFile: File, configBuilder: (File) -> T, logger: Logger ): T { - require(config == null) { - "The ${config?.configName} config was already parsed" - } - logger.info("Building ${config?.configName} config...") - return configBuilder(configFile) + val config = configBuilder(configFile) + logger.info("config ${config.configName} has been built...") + return config }