Allow to run scratch without module selected

^KT-23985 Fixed
This commit is contained in:
Natalia Selezneva
2018-12-05 09:39:14 +03:00
parent 8d4ca4d1c5
commit e2b5134048
11 changed files with 68 additions and 30 deletions
@@ -54,7 +54,7 @@ class KotlinConsoleKeeper(val project: Project) {
companion object {
@JvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, KotlinConsoleKeeper::class.java)
fun createCommandLine(module: Module): GeneralCommandLine {
fun createCommandLine(module: Module?): GeneralCommandLine {
val javaParameters = createJavaParametersWithSdk(module)
javaParameters.mainClass = "dummy"
@@ -79,16 +79,18 @@ class KotlinConsoleKeeper(val project: Project) {
paramList.add("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
addPathToCompiledOutput(paramList, module)
if (module != null) {
addPathToCompiledOutput(paramList, module)
}
return commandLine
}
fun createJavaParametersWithSdk(module: Module): JavaParameters {
fun createJavaParametersWithSdk(module: Module?): JavaParameters {
val params = JavaParameters()
params.charset = null
val sdk = ModuleRootManager.getInstance(module).sdk
val sdk = module?.let { ModuleRootManager.getInstance(module).sdk }
if (sdk != null && sdk.sdkType is JavaSdkType && File(sdk.homePath).exists()) {
params.jdk = sdk
}