generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devin-lang): add AutoDevRunConfigurationProducer and related cla…
…sses #101 Adds a new producer for AutoDev run configurations, along with necessary classes for setting up and editing these configurations. This includes the `AutoDevConfigurationType`, `AutoDevConfiguration`, `AutoDevRunConfigurationProducer`, and `AutoDevSettingsEditor`. The changes also involve modifications to the `DevInRunLineMarkersProvider` to provide run actions for DevIn files, and the addition of new strings to `AutoDevBundle.properties` for localization.
- Loading branch information
Showing
7 changed files
with
127 additions
and
30 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
42 changes: 42 additions & 0 deletions
42
exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/run/AutoDevConfiguration.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,42 @@ | ||
package cc.unitmesh.devti.language.run | ||
|
||
import cc.unitmesh.devti.AutoDevIcons | ||
import com.intellij.execution.Executor | ||
import com.intellij.execution.configurations.RunConfiguration | ||
import com.intellij.execution.configurations.RunConfigurationBase | ||
import com.intellij.execution.configurations.RunProfileState | ||
import com.intellij.execution.runners.ExecutionEnvironment | ||
import com.intellij.openapi.options.SettingsEditor | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.ui.dsl.builder.panel | ||
import javax.swing.Icon | ||
import javax.swing.JComponent | ||
|
||
class AutoDevConfiguration(project: Project, name: String, factory: AutoDevConfigurationFactory) : | ||
RunConfigurationBase<AutoDevConfigurationOptions>(project, factory, name) { | ||
override fun getIcon(): Icon = AutoDevIcons.AI_COPILOT | ||
|
||
override fun getState(executor: Executor, environment: ExecutionEnvironment): RunProfileState? { | ||
return null | ||
} | ||
|
||
override fun clone(): RunConfiguration { | ||
return super.clone() as AutoDevConfiguration | ||
} | ||
|
||
override fun getConfigurationEditor(): SettingsEditor<out RunConfiguration> { | ||
return AutoDevSettingsEditor(project) | ||
} | ||
} | ||
|
||
class AutoDevSettingsEditor(project: Project) : SettingsEditor<AutoDevConfiguration>() { | ||
override fun createEditor(): JComponent = panel { | ||
|
||
} | ||
|
||
override fun resetEditorFrom(configuration: AutoDevConfiguration) { | ||
} | ||
|
||
override fun applyEditorTo(configuration: AutoDevConfiguration) { | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
...in-lang/src/main/kotlin/cc/unitmesh/devti/language/run/AutoDevRunConfigurationProducer.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,38 @@ | ||
package cc.unitmesh.devti.language.run | ||
|
||
import cc.unitmesh.devti.language.psi.DevInFile | ||
import com.intellij.execution.actions.ConfigurationContext | ||
import com.intellij.execution.actions.LazyRunConfigurationProducer | ||
import com.intellij.openapi.util.Ref | ||
import com.intellij.psi.PsiElement | ||
|
||
class AutoDevRunConfigurationProducer : LazyRunConfigurationProducer<AutoDevConfiguration>() { | ||
override fun getConfigurationFactory(): AutoDevConfigurationFactory { | ||
return AutoDevConfigurationFactory(AutoDevConfigurationType.getInstance()) | ||
} | ||
|
||
override fun setupConfigurationFromContext( | ||
configuration: AutoDevConfiguration, | ||
context: ConfigurationContext, | ||
sourceElement: Ref<PsiElement>, | ||
): Boolean { | ||
val psiFile = sourceElement.get().containingFile as? DevInFile ?: return false | ||
val virtualFile = psiFile.virtualFile ?: return false | ||
|
||
configuration.name = "Run DevIn file: ${virtualFile.name}" | ||
|
||
return true | ||
} | ||
|
||
override fun isConfigurationFromContext( | ||
configuration: AutoDevConfiguration, | ||
context: ConfigurationContext, | ||
): Boolean { | ||
val psiLocation = context.psiLocation ?: return false | ||
val psiFile = psiLocation.containingFile as? DevInFile ?: return false | ||
val virtualFile = psiFile.virtualFile ?: return false | ||
|
||
return configuration.name == "Run DevIn file: ${virtualFile.name}" | ||
} | ||
|
||
} |
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