Repl: fix paths on windows

This commit is contained in:
Pavel V. Talanov
2015-09-11 16:20:11 +03:00
parent 8a944e099e
commit 30d675d49f
4 changed files with 20 additions and 8 deletions
@@ -47,4 +47,7 @@ public interface KotlinPaths {
@NotNull
File getJsStdLibSrcJarPath();
@NotNull
File getCompilerPath();
}
@@ -82,6 +82,12 @@ public class KotlinPathsFromHomeDir implements KotlinPaths {
return getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME);
}
@NotNull
@Override
public File getCompilerPath() {
return getLibraryFile(PathUtil.KOTLIN_COMPILER_JAR);
}
@NotNull
private File getLibraryFile(@NotNull String fileName) {
return new File(getLibPath(), fileName);
@@ -38,8 +38,9 @@ public class PathUtil {
public static final String KOTLIN_JAVA_RUNTIME_JAR = "kotlin-runtime.jar";
public static final String KOTLIN_JAVA_REFLECT_JAR = "kotlin-reflect.jar";
public static final String KOTLIN_JAVA_RUNTIME_SRC_JAR = "kotlin-runtime-sources.jar";
public static final String HOME_FOLDER_NAME = "kotlinc";
public static final String KOTLIN_COMPILER_JAR = "kotlin-compiler.jar";
public static final String HOME_FOLDER_NAME = "kotlinc";
private static final File NO_PATH = new File("<no_path>");
private PathUtil() {}
@@ -90,7 +91,7 @@ public class PathUtil {
if (!jar.exists()) return NO_PATH;
if (jar.getName().equals("kotlin-compiler.jar")) {
if (jar.getName().equals(KOTLIN_COMPILER_JAR)) {
File lib = jar.getParentFile();
return lib.getParentFile();
}
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.SystemProperties
import org.jetbrains.kotlin.console.actions.errorNotification
import org.jetbrains.kotlin.utils.PathUtil
import org.jetbrains.kotlin.utils.join
import java.io.File
import java.util.concurrent.ConcurrentHashMap
@@ -64,21 +65,22 @@ public class KotlinConsoleKeeper(val project: Project) {
val commandLine = JdkUtil.setupJVMCommandLine(exePath, javaParameters, true)
// set parameters to run compiler
val paramList = commandLine.parametersList
paramList.clearAll()
// use to debug repl process
//paramList.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")
// set classpath for process to compiler
paramList.add("-cp")
paramList.add("${PathUtil.getKotlinPathsForIdeaPlugin().libPath.absolutePath}/*")
val kotlinPaths = PathUtil.getKotlinPathsForIdeaPlugin()
val replClassPath = listOf(kotlinPaths.compilerPath, kotlinPaths.reflectPath, kotlinPaths.runtimePath)
.map { it.absolutePath }
.joinToString(File.pathSeparator)
paramList.add("-cp")
paramList.add(replClassPath)
// set param to prevent process from repeating input backwards
paramList.add("-Drepl.ideMode=true")
// path to compiler and his options
paramList.add("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
addPathToCompiledOutput(paramList, module)