J2K PathUtil: convert and prettify

This commit is contained in:
Alexander Udalov
2017-07-05 19:24:37 +03:00
parent 3beb6a86f7
commit 46a01ec131
28 changed files with 158 additions and 178 deletions
@@ -24,7 +24,6 @@ import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.JavaSdkType
import com.intellij.openapi.projectRoots.JdkUtil
import com.intellij.openapi.projectRoots.SimpleJavaSdkType
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.OrderEnumerator
@@ -68,7 +67,7 @@ class KotlinConsoleKeeper(val project: Project) {
// use to debug repl process
//paramList.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")
val kotlinPaths = PathUtil.getKotlinPathsForIdeaPlugin()
val kotlinPaths = PathUtil.kotlinPathsForIdeaPlugin
val replClassPath = listOf(kotlinPaths.compilerPath, kotlinPaths.reflectPath, kotlinPaths.stdlibPath, kotlinPaths.scriptRuntimePath)
.joinToString(File.pathSeparator) { it.absolutePath }
@@ -112,4 +111,4 @@ class KotlinConsoleKeeper(val project: Project) {
companion object {
@JvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, KotlinConsoleKeeper::class.java)
}
}
}
@@ -44,7 +44,7 @@ class KotlinJsr223JvmScriptEngine4Idea(
) : KotlinJsr223JvmScriptEngineBase(factory) {
private val daemon by lazy {
val path = PathUtil.getKotlinPathsForIdeaPlugin().compilerPath
val path = PathUtil.kotlinPathsForIdeaPlugin.compilerPath
assert(path.exists())
val compilerId = CompilerId.makeCompilerId(path)
val daemonOptions = configureDaemonOptions()
@@ -58,7 +58,7 @@ fun classpathFromClassloader(classLoader: ClassLoader): List<File>? =
private val kotlinCompilerJar: File by lazy {
// highest prio - explicit property
System.getProperty("kotlin.compiler.jar")?.let(::File)?.takeIf(File::exists)
?: PathUtil.getKotlinPathsForIdeaPlugin().compilerPath
?: PathUtil.kotlinPathsForIdeaPlugin.compilerPath
?: throw FileNotFoundException("Cannot find kotlin compiler jar, set kotlin.compiler.jar property to proper location")
}
@@ -83,4 +83,4 @@ private val kotlinScriptRuntimeJar: File? by lazy {
?: File(kotlinCompilerJar.parentFile, KOTLIN_JAVA_SCRIPT_RUNTIME_JAR).takeIf(File::exists)
}
private val kotlinScriptStandardJars by lazy { listOf(kotlinStdlibJar, kotlinScriptRuntimeJar) }
private val kotlinScriptStandardJars by lazy { listOf(kotlinStdlibJar, kotlinScriptRuntimeJar) }
@@ -59,15 +59,13 @@ object ConfigLibraryUtil {
fun configureKotlinJsRuntimeAndSdk(module: Module, sdk: Sdk) {
configureSdk(module, sdk)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_JS_STDLIB_NAME,
PathUtil.getKotlinPathsForDistDirectory().jsStdLibJarPath), module,
PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath), module,
JSLibraryKind)
}
fun configureKotlinRuntime(module: Module) {
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_JAVA_RUNTIME_LIB_NAME, PathUtil.getKotlinPathsForDistDirectory().stdlibPath),
module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_TEST_LIB_NAME, PathUtil.getKotlinPathsForDistDirectory().kotlinTestPath),
module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_JAVA_RUNTIME_LIB_NAME, PathUtil.kotlinPathsForDistDirectory.stdlibPath), module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_TEST_LIB_NAME, PathUtil.kotlinPathsForDistDirectory.kotlinTestPath), module)
}
fun unConfigureKotlinRuntime(module: Module) {
@@ -191,7 +191,7 @@ private class ScriptCommandLineState(
val scriptVFile = LocalFileSystem.getInstance().findFileByIoFile(File(filePath)) ?:
throw CantRunException("Script file was not found in project")
params.classPath.add(PathUtil.getKotlinPathsForIdeaPlugin().compilerPath)
params.classPath.add(PathUtil.kotlinPathsForIdeaPlugin.compilerPath)
val scriptClasspath = ScriptDependenciesManager.getInstance(environment.project).getScriptClasspath(scriptVFile)
scriptClasspath.forEach {
@@ -60,7 +60,7 @@ class BundledKotlinScriptDependenciesResolver : DependenciesResolver {
val javaHome = environment.get("sdk") as String?
val dependencies = ScriptDependencies(
javaHome = javaHome?.let(::File),
classpath = with(PathUtil.getKotlinPathsForIdeaPlugin()) {
classpath = with(PathUtil.kotlinPathsForIdeaPlugin) {
listOf(
reflectPath,
stdlibPath,
@@ -198,7 +198,7 @@ enum class LibraryJarDescriptor(val jarName: String,
return LibraryUtils.getJarFile(Arrays.asList(*library.getFiles(orderRootType)), jarName)
}
fun getPathInPlugin() = getPath(PathUtil.getKotlinPathsForIdeaPlugin())
fun getPathInPlugin() = getPath(PathUtil.kotlinPathsForIdeaPlugin)
}
fun bundledRuntimeVersion(): String {
@@ -206,7 +206,7 @@ fun bundledRuntimeVersion(): String {
}
private val bundledRuntimeBuildNumber: String? by lazy {
val file = PathUtil.getKotlinPathsForIdeaPlugin().buildNumberFile
val file = PathUtil.kotlinPathsForIdeaPlugin.buildNumberFile
if (file.exists()) file.readText().trim() else null
}
@@ -190,10 +190,10 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() {
}
private val pathToExistentRuntimeJar: String
get() = PathUtil.getKotlinPathsForDistDirectory().stdlibPath.parent
get() = PathUtil.kotlinPathsForDistDirectory.stdlibPath.parent
private val pathToExistentJsJar: String
get() = PathUtil.getKotlinPathsForDistDirectory().jsStdLibJarPath.parent
get() = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath.parent
protected fun assertNotConfigured(module: Module, configurator: KotlinWithLibraryConfigurator) {
TestCase.assertFalse(
@@ -73,7 +73,7 @@ abstract class AbstractScriptConfigurationTest : AbstractPsiCheckerTest() {
protected fun configureScriptEnvironment(path: String) {
val templateOutDir = compileLibToDir(
File("${path}template"),
PathUtil.getKotlinPathsForDistDirectory().scriptRuntimePath.path
PathUtil.kotlinPathsForDistDirectory.scriptRuntimePath.path
)
val libSrcDir = File("${path}lib")