forked from JetBrains-Research/paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Run Line Marker for paddle run tasks
Fix a bug with version specifiers
- Loading branch information
Oleg Smirnov
committed
Jul 5, 2022
1 parent
38c9097
commit 89314f0
Showing
10 changed files
with
118 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
idea/src/main/kotlin/io/paddle/idea/execution/PaddleRunConfigurationProducer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.paddle.idea.execution | ||
|
||
import com.intellij.execution.actions.ConfigurationContext | ||
import com.intellij.execution.actions.ConfigurationFromContext | ||
import com.intellij.execution.configurations.ConfigurationFactory | ||
import com.intellij.openapi.externalSystem.service.execution.* | ||
import com.intellij.openapi.util.Ref | ||
import com.intellij.psi.PsiElement | ||
import com.jetbrains.python.sdk.basePath | ||
import io.paddle.idea.PaddleManager | ||
import org.jetbrains.yaml.psi.YAMLKeyValue | ||
|
||
class PaddleRunConfigurationProducer : AbstractExternalSystemRunConfigurationProducer() { | ||
override fun getConfigurationFactory(): ConfigurationFactory { | ||
return PaddleTaskConfigurationType.getInstance().factory | ||
} | ||
|
||
override fun setupConfigurationFromContext( | ||
configuration: ExternalSystemRunConfiguration, | ||
context: ConfigurationContext, | ||
sourceElement: Ref<PsiElement> | ||
): Boolean { | ||
if (context.location is ExternalSystemTaskLocation) { | ||
return super.setupConfigurationFromContext(configuration, context, sourceElement) | ||
} | ||
|
||
if (configuration.settings.externalSystemId != PaddleManager.ID || configuration !is PaddleRunConfiguration) return false | ||
if (context.location?.psiElement?.parent !is YAMLKeyValue) return false | ||
val runTaskId = (context.location?.psiElement?.parent as YAMLKeyValue).value?.text ?: return false | ||
val module = context.location?.module ?: return false | ||
|
||
configuration.settings.taskNames = listOf("run$$runTaskId") | ||
configuration.settings.externalProjectPath = module.basePath | ||
configuration.name = AbstractExternalSystemTaskConfigurationType.generateName(module.project, configuration.settings) | ||
|
||
return true | ||
} | ||
|
||
override fun isConfigurationFromContext(configuration: ExternalSystemRunConfiguration, context: ConfigurationContext): Boolean { | ||
if (context.location is ExternalSystemTaskLocation) { | ||
return super.isConfigurationFromContext(configuration, context) | ||
} | ||
|
||
if (configuration.settings.externalSystemId != PaddleManager.ID || configuration !is PaddleRunConfiguration) return false | ||
val module = context.location?.module ?: return false | ||
if (configuration.settings.externalProjectPath != module.basePath) return false | ||
|
||
if (context.location?.psiElement?.parent !is YAMLKeyValue) return false | ||
val runTaskId = (context.location?.psiElement?.parent as YAMLKeyValue).value?.text ?: return false | ||
val taskNames = configuration.settings.taskNames.takeIf { it.isNotEmpty() } ?: return false | ||
if (taskNames.first() != "run$$runTaskId") return false | ||
|
||
return true | ||
} | ||
|
||
override fun isPreferredConfiguration(self: ConfigurationFromContext?, other: ConfigurationFromContext): Boolean { | ||
return other.isProducedBy(PaddleRunConfigurationProducer::class.java) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
idea/src/main/kotlin/io/paddle/idea/execution/PaddleRunLineMarkerContributor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.paddle.idea.execution | ||
|
||
import com.intellij.execution.lineMarker.ExecutorAction | ||
import com.intellij.execution.lineMarker.RunLineMarkerContributor | ||
import com.intellij.icons.AllIcons | ||
import com.intellij.psi.PsiElement | ||
import io.paddle.idea.utils.getSuperParent | ||
|
||
class PaddleRunLineMarkerContributor : RunLineMarkerContributor() { | ||
override fun getInfo(element: PsiElement): Info? { | ||
if (element.containingFile.name != "paddle.yaml") return null | ||
|
||
if (element.text.contains("id") | ||
&& element.getSuperParent(5).text.startsWith("run") | ||
&& element.getSuperParent(7).text.startsWith("tasks") | ||
) { | ||
val actions = ExecutorAction.getActions(Integer.MAX_VALUE) | ||
return Info(AllIcons.RunConfigurations.TestState.Run, actions) { e -> | ||
actions.mapNotNull { getText(it, e) }.joinToString("\n") | ||
} | ||
} | ||
|
||
return null | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
idea/src/main/kotlin/io/paddle/idea/execution/PaddleRuntimeConfigurationProducer.kt
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
idea/src/main/kotlin/io/paddle/idea/execution/PaddleTasksExecutionSettingsBuilder.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters