Skip to content

Commit

Permalink
[ML4SE-234] new ScenarioStep.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 committed Nov 9, 2023
1 parent 7253f6a commit 682e66f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jetbrains.research.tasktracker.config.ide

import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import kotlinx.serialization.Serializable
import org.jetbrains.research.tasktracker.config.BaseProjectConfig
import org.jetbrains.research.tasktracker.config.ide.inspection.InspectionConfig
import org.jetbrains.research.tasktracker.config.ide.settings.SettingsConfig
Expand All @@ -10,9 +11,11 @@ import org.jetbrains.research.tasktracker.handler.BaseProjectHandler
import org.jetbrains.research.tasktracker.handler.ide.IdeHandler
import java.io.File

class MainIdeConfig : BaseProjectConfig {
var inspectionConfig: InspectionConfig? = null
@Serializable
data class MainIdeConfig(
var inspectionConfig: InspectionConfig? = null,
var settingsConfig: SettingsConfig? = null
) : BaseProjectConfig {
override val configName: String
get() = "main_ide"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.research.tasktracker.config.scenario
import kotlinx.serialization.Serializable
import org.jetbrains.research.tasktracker.config.BaseConfig
import org.jetbrains.research.tasktracker.config.YamlConfigLoadStrategy
import org.jetbrains.research.tasktracker.config.scenario.models.Scenario
import java.io.File

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.research.tasktracker.config.scenario
package org.jetbrains.research.tasktracker.config.scenario.models

import com.intellij.openapi.diagnostic.Logger
import kotlinx.serialization.KSerializer
Expand All @@ -8,31 +8,8 @@ import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import org.jetbrains.research.tasktracker.TaskTrackerPlugin
import org.jetbrains.research.tasktracker.config.BaseConfig
import java.util.*

enum class ScenarioUnitType {
TASK_CONTENT,

// TODO: add other types of content
IDE_SETTINGS;

val config: BaseConfig?
get() = when (this) {
TASK_CONTENT -> TaskTrackerPlugin.mainConfig.taskContentConfig
IDE_SETTINGS -> TaskTrackerPlugin.mainConfig.mainIdeConfig
}
}

@Serializable
data class ScenarioStep(
// TODO: sort according to the plugin's implementation to make sure in the right order
val units: List<ScenarioUnitType>
) {
fun isValid() = units.any { it.config != null }
}

@Serializable
data class Scenario(
@Serializable(with = QueueSerializer::class) val steps: Queue<ScenarioStep>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jetbrains.research.tasktracker.config.scenario.models

import com.intellij.openapi.project.Project
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import org.jetbrains.research.tasktracker.config.BaseConfig
import org.jetbrains.research.tasktracker.config.ide.MainIdeConfig
import org.jetbrains.research.tasktracker.handler.BaseProjectHandler

@Serializable
data class ScenarioStep(
private val ideConfig: MainIdeConfig?,
val units: List<BaseConfig>,
val mode: ScenarioStepMode = ScenarioStepMode.ORDERED
) {
@Transient
private var mainIdeHandler: BaseProjectHandler? = null

fun prepareSettings(project: Project) {
mainIdeHandler = ideConfig?.buildHandler(project)
mainIdeHandler?.setup()
}

fun run() {
TODO()
}

// TODO check if there are any config of specified type in units.
@Suppress("FunctionOnlyReturningConstant")
fun isValid() = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jetbrains.research.tasktracker.config.scenario.models

enum class ScenarioStepMode {
ORDERED,
SHUFFLED
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jetbrains.research.tasktracker.handler.scenario

import org.jetbrains.research.tasktracker.config.MainTaskTrackerConfig
import org.jetbrains.research.tasktracker.config.scenario.ScenarioStep
import org.jetbrains.research.tasktracker.config.scenario.ScenarioUnitType
import org.jetbrains.research.tasktracker.config.scenario.models.ScenarioStep
import org.jetbrains.research.tasktracker.config.scenario.models.ScenarioUnitType

@Suppress("UnusedPrivateMember")
class ScenarioHandler(private val mainConfig: MainTaskTrackerConfig) {
Expand Down

0 comments on commit 682e66f

Please sign in to comment.