generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 18
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
1 parent
08d9f02
commit 80e11ac
Showing
10 changed files
with
138 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,23 @@ | ||
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html | ||
pluginName=intellij-aicoder | ||
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder | ||
# SemVer format -> https://semver.org | ||
pluginVersion=1.2.23 | ||
|
||
jvmArgs=-Xmx4g | ||
|
||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html | ||
#pluginSinceBuild = 203 | ||
pluginSinceBuild=231 | ||
pluginUntilBuild=233.* | ||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension | ||
# IntelliJ IDEA Community | ||
pluginSinceBuild=232 | ||
pluginUntilBuild=232.* | ||
|
||
platformType = IC | ||
# CLion | ||
#platformType = CL | ||
#platformPlugins = org.rust.lang:0.4.171.4656-213 | ||
#platformPlugins = org.rust.lang:0.4.187.5175-223 | ||
# IntelliJ IDEA Ultimate | ||
#platformType=IU | ||
# https://mvnrepository.com/artifact/com.jetbrains.intellij.idea/ideaIU | ||
platformVersion=2023.2.5 | ||
platformPlugins=com.intellij.java | ||
# PhpStorm | ||
#platformType = PS | ||
#platformPlugins = com.jetbrains.php | ||
# Rider | ||
#platformType = RD | ||
#platformPlugins = JavaScript | ||
#platformType = PY | ||
#platformPlugins = Pythonid | ||
# Gradle Releases -> https://github.com/gradle/gradle/releases | ||
gradleVersion=8.4 | ||
|
||
# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library | ||
# suppress inspection "UnusedProperty" | ||
kotlin.stdlib.default.dependency=false | ||
|
||
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html | ||
org.gradle.configuration-cache = false | ||
|
||
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html | ||
org.gradle.caching = true | ||
|
||
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#incremental-compilation | ||
kotlin.incremental.useClasspathSnapshot=false | ||
|
||
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment | ||
systemProp.org.gradle.unsafe.kotlin.assignment = true |
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
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/com/github/simiacryptus/aicoder/util/IdeaKotlinInterpreter.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,44 @@ | ||
package com.github.simiacryptus.aicoder.util | ||
|
||
import com.intellij.lang.Language | ||
import com.intellij.openapi.application.runReadAction | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiFileFactory | ||
import com.simiacryptus.skyenet.kotlin.KotlinInterpreter | ||
import org.jetbrains.kotlin.jsr223.KotlinJsr223StandardScriptEngineFactory4Idea | ||
import org.jetbrains.kotlin.resolve.AnalyzingUtils | ||
import org.slf4j.LoggerFactory | ||
import java.util.Map | ||
|
||
class IdeaKotlinInterpreter(defs: Map<String, Object>) : KotlinInterpreter(defs) { | ||
companion object { | ||
private val log = LoggerFactory.getLogger(IdeaKotlinInterpreter::class.java) | ||
|
||
var project: Project? = null | ||
} | ||
override val scriptEngine: javax.script.ScriptEngine | ||
get() = KotlinJsr223StandardScriptEngineFactory4Idea().scriptEngine | ||
override fun validate(code: String) = try { | ||
val messageCollector = MessageCollectorImpl(code) | ||
val psiFileFactory = PsiFileFactory.getInstance(project!!) | ||
runReadAction { | ||
AnalyzingUtils.checkForSyntacticErrors( | ||
psiFileFactory.createFileFromText( | ||
"Dummy.kt", | ||
Language.findLanguageByID("kotlin")!!, | ||
code | ||
) | ||
) | ||
} | ||
if (messageCollector.errors.isEmpty()) { | ||
null | ||
} else RuntimeException( | ||
""" | ||
|${messageCollector.errors.joinToString("\n") { "Error: $it" }} | ||
|${messageCollector.warnings.joinToString("\n") { "Warning: $it" }} | ||
""".trimMargin() | ||
) | ||
} catch (e: Throwable) { | ||
e | ||
} | ||
} |
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