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.
- Loading branch information
Showing
1 changed file
with
10 additions
and
10 deletions.
There are no files selected for viewing
20 changes: 10 additions & 10 deletions
20
src/main/kotlin/cc/unitmesh/devti/runconfig/DtRunConfigurationOptions.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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
package cc.unitmesh.devti.runconfig | ||
|
||
import com.intellij.execution.configurations.RunConfigurationOptions | ||
import cc.unitmesh.devti.ai.OpenAIVersion | ||
import com.intellij.execution.configurations.ModuleBasedConfigurationOptions | ||
import com.intellij.openapi.components.StoredProperty | ||
import com.intellij.openapi.diagnostic.Logger | ||
|
||
// ModuleBasedConfigurationOptions | ||
class DtRunConfigurationOptions : RunConfigurationOptions() { | ||
class DtRunConfigurationOptions : ModuleBasedConfigurationOptions() { | ||
private val githubToken: StoredProperty<String?> = string("").provideDelegate(this, "githubToken") | ||
private val openAiApiKey: StoredProperty<String?> = string("").provideDelegate(this, "openAiApiKey") | ||
private val openAiEngine: StoredProperty<String?> = string("").provideDelegate(this, "openAiEngine") | ||
private val openAiMaxTokens: StoredProperty<Int> = property(4096).provideDelegate(this, "openAiMaxTokens") | ||
private val aiVersion: StoredProperty<Int> = property(1).provideDelegate(this, "aiVersion") | ||
private val maxTokens: StoredProperty<Int> = property(4096).provideDelegate(this, "aiMaxTokens") | ||
|
||
fun setFrom(configure: DevtiConfigure) { | ||
this.githubToken.setValue(this, configure.githubToken) | ||
this.openAiApiKey.setValue(this, configure.openAiApiKey) | ||
this.openAiEngine.setValue(this, configure.aiVersion) | ||
this.openAiMaxTokens.setValue(this, configure.aiMaxTokens) | ||
this.aiVersion.setValue(this, configure.aiVersion.index) | ||
this.maxTokens.setValue(this, configure.aiMaxTokens) | ||
} | ||
|
||
fun toConfigure(): DevtiConfigure { | ||
return DevtiConfigure( | ||
githubToken.getValue(this) ?: "", | ||
openAiApiKey.getValue(this) ?: "", | ||
openAiEngine.getValue(this) ?: "", | ||
openAiMaxTokens.getValue(this) ?: 4096 | ||
OpenAIVersion.fromIndex(aiVersion.getValue(this) ?: 1), | ||
maxTokens.getValue(this) ?: 4096 | ||
) | ||
} | ||
|
||
companion object { | ||
val logger = Logger.getInstance(DtRunConfigurationOptions::class.java) | ||
val logger = Logger.getInstance(DtRunConfigurationOptions::class.java) | ||
} | ||
} |