Skip to content

Commit

Permalink
[ML4SE-158] refactored buildBaseConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 committed Oct 16, 2023
1 parent 389f80e commit a2c7833
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class MainIdeConfig : BaseConfig {
when {
configFile.name.startsWith(InspectionConfig.CONFIG_FILE_PREFIX) -> {
mainIdeConfig.inspectionConfig = buildBaseConfig(
mainIdeConfig.inspectionConfig,
configFile,
InspectionConfig::buildConfig,
logger
Expand All @@ -35,7 +34,6 @@ class MainIdeConfig : BaseConfig {

configFile.name.startsWith(SettingsConfig.CONFIG_FILE_PREFIX) -> {
mainIdeConfig.settingsConfig = buildBaseConfig(
mainIdeConfig.settingsConfig,
configFile,
SettingsConfig::buildConfig,
logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import org.jetbrains.research.tasktracker.config.BaseConfig
import java.io.File

inline fun <reified T : BaseConfig> 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
}

0 comments on commit a2c7833

Please sign in to comment.