Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New scenario #80

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[ML4SE-234] new Scenario Step
mikrise2 committed Nov 15, 2023
commit 41379702ec48b4dc0bc2174090a4bcfd609cfac9
Original file line number Diff line number Diff line change
@@ -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
@@ -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"

Original file line number Diff line number Diff line change
@@ -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
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
@@ -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>
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) {