Run script action in IDE should use kotlin compiler from plugin
^KT-22647 Fixed
This commit is contained in:
+2
@@ -201,6 +201,8 @@ private class ScriptCommandLineState(
|
|||||||
params.mainClass = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
params.mainClass = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
||||||
params.programParametersList.prepend(filePath)
|
params.programParametersList.prepend(filePath)
|
||||||
params.programParametersList.prepend("-script")
|
params.programParametersList.prepend("-script")
|
||||||
|
params.programParametersList.prepend(PathUtil.kotlinPathsForIdeaPlugin.homePath.path)
|
||||||
|
params.programParametersList.prepend("-kotlin-home")
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.idea.search.allScope
|
|||||||
import org.jetbrains.kotlin.idea.stubindex.KotlinScriptFqnIndex
|
import org.jetbrains.kotlin.idea.stubindex.KotlinScriptFqnIndex
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinCodeInsightTestCase
|
import org.jetbrains.kotlin.idea.test.KotlinCodeInsightTestCase
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
import org.jetbrains.kotlin.psi.KtScript
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import kotlin.test.assertNotEquals
|
import kotlin.test.assertNotEquals
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ class StandaloneScriptRunConfigurationTest : KotlinCodeInsightTestCase() {
|
|||||||
|
|
||||||
val javaParameters = getJavaRunParameters(runConfiguration)
|
val javaParameters = getJavaRunParameters(runConfiguration)
|
||||||
val programParametersList = javaParameters.programParametersList.list
|
val programParametersList = javaParameters.programParametersList.list
|
||||||
val (first, second) = programParametersList
|
|
||||||
Assert.assertEquals("Should pass -script to compiler", "-script", first)
|
programParametersList.checkParameter("-script") { it.contains("simpleScript.kts") }
|
||||||
Assert.assertTrue("Should pass script file to compiler", second.contains("simpleScript.kts"))
|
programParametersList.checkParameter("-kotlin-home") { it == PathUtil.kotlinPathsForIdeaPlugin.homePath.path }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testOnFileRename() {
|
fun testOnFileRename() {
|
||||||
@@ -122,6 +122,12 @@ class StandaloneScriptRunConfigurationTest : KotlinCodeInsightTestCase() {
|
|||||||
assertEquals(originalWorkingDirectory, runConfiguration.workingDirectory)
|
assertEquals(originalWorkingDirectory, runConfiguration.workingDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun List<String>.checkParameter(name: String, condition: (String) -> Boolean) {
|
||||||
|
val param = find { it == name } ?: throw AssertionError("Should pass $name to compiler")
|
||||||
|
val paramValue = this[this.indexOf(param) + 1]
|
||||||
|
Assert.assertTrue("Check for $name parameter fails: actual value = $paramValue", condition(paramValue))
|
||||||
|
}
|
||||||
|
|
||||||
fun moveScriptFile(scriptFile: PsiFile) {
|
fun moveScriptFile(scriptFile: PsiFile) {
|
||||||
ActionRunner.runInsideWriteAction { VfsUtil.createDirectoryIfMissing(scriptFile.virtualFile.parent, "dest") }
|
ActionRunner.runInsideWriteAction { VfsUtil.createDirectoryIfMissing(scriptFile.virtualFile.parent, "dest") }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user