generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
132 additions
and
13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType | ||
|
||
plugins { | ||
id("org.jetbrains.intellij.platform.module") | ||
alias(libs.plugins.kotlin) // Kotlin support | ||
} | ||
|
||
dependencies { | ||
implementation(project(":mise-core")) | ||
|
||
// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin | ||
intellijPlatform { | ||
create(IntelliJPlatformType.PyCharmCommunity, providers.gradleProperty("platformVersion"), false) | ||
|
||
bundledPlugins("PythonCore") | ||
|
||
instrumentationTools() | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...arm/src/main/kotlin/com/github/l34130/mise/runconfigs/PyCharmRunConfigurationExtension.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,82 @@ | ||
package com.github.l34130.mise.runconfigs | ||
|
||
import com.github.l34130.mise.commands.MiseCmd | ||
import com.github.l34130.mise.notifications.Notification | ||
import com.github.l34130.mise.settings.ui.RunConfigurationSettingsEditor | ||
import com.intellij.execution.configurations.GeneralCommandLine | ||
import com.intellij.execution.configurations.RunnerSettings | ||
import com.intellij.notification.NotificationType | ||
import com.intellij.openapi.options.SettingsEditor | ||
import com.intellij.openapi.project.Project | ||
import com.jetbrains.python.run.AbstractPythonRunConfiguration | ||
import com.jetbrains.python.run.PythonExecution | ||
import com.jetbrains.python.run.PythonRunConfigurationExtension | ||
import com.jetbrains.python.run.PythonRunParams | ||
import com.jetbrains.python.run.target.HelpersAwareTargetEnvironmentRequest | ||
import com.jetbrains.python.run.target.PythonCommandLineTargetEnvironmentProvider | ||
import org.jdom.Element | ||
|
||
class PyCharmRunConfigurationExtension : | ||
PythonRunConfigurationExtension(), | ||
PythonCommandLineTargetEnvironmentProvider { | ||
override fun getEditorTitle(): String = RunConfigurationSettingsEditor.EDITOR_TITLE | ||
|
||
override fun <P : AbstractPythonRunConfiguration<*>> createEditor(configuration: P): SettingsEditor<P> = | ||
RunConfigurationSettingsEditor(configuration) | ||
|
||
override fun getSerializationId(): String = RunConfigurationSettingsEditor.SERIALIZATION_ID | ||
|
||
override fun readExternal( | ||
runConfiguration: AbstractPythonRunConfiguration<*>, | ||
element: Element, | ||
) { | ||
RunConfigurationSettingsEditor.readExternal(runConfiguration, element) | ||
} | ||
|
||
override fun writeExternal( | ||
runConfiguration: AbstractPythonRunConfiguration<*>, | ||
element: Element, | ||
) { | ||
RunConfigurationSettingsEditor.writeExternal(runConfiguration, element) | ||
} | ||
|
||
override fun patchCommandLine( | ||
configuration: AbstractPythonRunConfiguration<*>, | ||
runnerSettings: RunnerSettings?, | ||
cmdLine: GeneralCommandLine, | ||
runnerId: String, | ||
) { | ||
Notification.notify("Patching command line for Pythonid run configuration", NotificationType.INFORMATION) | ||
Notification.notify("${cmdLine.environment}", NotificationType.INFORMATION) | ||
Notification.notify(configuration.getWorkingDirectorySafe(), NotificationType.INFORMATION) | ||
|
||
if (RunConfigurationSettingsEditor.isMiseEnabled(configuration)) { | ||
cmdLine.environment.putAll(MiseCmd.loadEnv(configuration.workingDirectory)) | ||
} | ||
} | ||
|
||
override fun isApplicableFor(configuration: AbstractPythonRunConfiguration<*>): Boolean = true | ||
|
||
override fun isEnabledFor( | ||
applicableConfiguration: AbstractPythonRunConfiguration<*>, | ||
runnerSettings: RunnerSettings?, | ||
): Boolean = true | ||
|
||
override fun extendTargetEnvironment( | ||
project: Project, | ||
helpersAwareTargetRequest: HelpersAwareTargetEnvironmentRequest, | ||
pythonExecution: PythonExecution, | ||
runParams: PythonRunParams, | ||
) { | ||
if (runParams is AbstractPythonRunConfiguration<*> && | ||
RunConfigurationSettingsEditor.isMiseEnabled(runParams) | ||
) { | ||
MiseCmd.loadEnv(runParams.workingDirectory).forEach { (k, v) -> | ||
pythonExecution.addEnvironmentVariable(k, v) | ||
} | ||
runParams.getEnvs().forEach { (k, v) -> | ||
pythonExecution.addEnvironmentVariable(k, v) | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="Pythonid"> | ||
<runConfigurationExtension implementation="com.github.l34130.mise.runconfigs.PyCharmRunConfigurationExtension" | ||
id="misePyCharm"/> | ||
<pythonCommandLineTargetEnvironmentProvider implementation="com.github.l34130.mise.runconfigs.PyCharmRunConfigurationExtension"/> | ||
</extensions> | ||
</idea-plugin> |
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