From f1d8c92bab77885815d5ef23e2d22dad3a0e2587 Mon Sep 17 00:00:00 2001 From: mikrise2 Date: Mon, 27 Nov 2023 10:52:02 +0100 Subject: [PATCH] [ML4SE-234] fixed PR comments. --- config/detekt.yml | 2 +- .../tasktracker/activities/InitActivity.kt | 7 ------ .../config/scenario/models/Scenario.kt | 22 +++++++++++-------- .../ui/main/panel/MainPluginPanelFactory.kt | 1 + .../main/panel/panelStates/DefaultStates.kt | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/config/detekt.yml b/config/detekt.yml index a799f00e..fe6adf14 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -22,7 +22,7 @@ formatting: complexity: TooManyFunctions: thresholdInObjects: 14 - thresholdInClasses: 14 + thresholdInClasses: 13 performance: SpreadOperator: diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/activities/InitActivity.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/activities/InitActivity.kt index e35b8fe1..97dc2c3d 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/activities/InitActivity.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/activities/InitActivity.kt @@ -18,12 +18,5 @@ class InitActivity : StartupActivity { // TODO: show an error message to the user if an error occurs override fun runActivity(project: Project) { TaskTrackerPlugin.initializationHandler.setupEnvironment(project) // TODO: move to the start point of the task - TaskTrackerPlugin.mainConfig.scenarioConfig?.let { scenarioConf -> -// scenarioConf.scenario.getNextStep()?.let { scenarioStep -> -// with(ScenarioHandler(TaskTrackerPlugin.mainConfig)) { -// scenarioStep.run() -// } -// } ?: logger.warn("Try to init the plugin, but the scenario is empty or invalid") - } ?: logger.warn("Please, provide a scenario for the plugin behaviour") } } diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/scenario/models/Scenario.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/scenario/models/Scenario.kt index 96e15753..1291f520 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/scenario/models/Scenario.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/scenario/models/Scenario.kt @@ -42,18 +42,22 @@ data class Scenario( @Suppress("ReturnCount") fun getNextUnit(project: Project): ScenarioUnit? { - if (currentStepIterator?.hasNext() != true) { - cleanStepSettings() - val currentStep = getNextStep() ?: return null - currentStep.prepareSettings(project) - currentStepIterator = currentStep.getUnits().iterator() - if (currentStepIterator?.hasNext() != true) { - return null - } + if (!currentStepIterator.notNullAndHasNext()) { + return null + } + cleanStepSettings() + val currentStep = getNextStep() ?: return null + currentStep.prepareSettings(project) + currentStepIterator = currentStep.getUnits().iterator() + return if (currentStepIterator.notNullAndHasNext()) { + currentStepIterator?.next() + } else { + null } - return currentStepIterator?.next() } + private fun Iterator?.notNullAndHasNext() = this?.hasNext() ?: false + private fun cleanStepSettings() = MainPanelStorage.activeIdeHandlers.forEach { it.destroy() diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/MainPluginPanelFactory.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/MainPluginPanelFactory.kt index 6dd1ea7a..4cd29e61 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/MainPluginPanelFactory.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/MainPluginPanelFactory.kt @@ -44,6 +44,7 @@ import java.awt.event.ActionListener * Note: This class requires JBCefApp to be supported for proper functioning. * */ +@Suppress("TooManyFunctions") class MainPluginPanelFactory : ToolWindowFactory { // TODO: init in other place, states can be saved between sessions private val nextButton = createJButton("ui.button.next") diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt index cda19d23..3ee93412 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt @@ -89,7 +89,7 @@ fun Panel.processTask(id: String): Task { private fun Panel.solveTask(id: String, nextTasks: List = emptyList()) { val task = processTask(id) val activityTracker = ActivityTracker(project) - activityTracker.startTracking() // TODO + activityTracker.startTracking() // TODO start tracking for all trackers instead of this one loadBasePage(SolvePageTemplate(task)) setNextAction { TaskFileHandler.disposeTask(project, task)