From eadec089375f2b38ae88147026b753621b380fef Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 22 Dec 2020 13:17:53 +0300 Subject: [PATCH] [Test] Reformat MockLibraryUtil according to code style --- .../jetbrains/kotlin/test/MockLibraryUtil.kt | 87 ++++++++++--------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/MockLibraryUtil.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/MockLibraryUtil.kt index b08bdb94603..e33c830397d 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/MockLibraryUtil.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/MockLibraryUtil.kt @@ -44,45 +44,53 @@ object MockLibraryUtil { @JvmStatic @JvmOverloads fun compileJvmLibraryToJar( - sourcesPath: String, - jarName: String, - addSources: Boolean = false, - allowKotlinSources: Boolean = true, - extraOptions: List = emptyList(), - extraClasspath: List = emptyList(), - useJava9: Boolean = false + sourcesPath: String, + jarName: String, + addSources: Boolean = false, + allowKotlinSources: Boolean = true, + extraOptions: List = emptyList(), + extraClasspath: List = emptyList(), + useJava9: Boolean = false ): File { return compileLibraryToJar( - sourcesPath, KtTestUtil.tmpDirForReusableFolder("testLibrary-" + jarName), jarName, addSources, allowKotlinSources, extraOptions, extraClasspath - , useJava9)} + sourcesPath, + KtTestUtil.tmpDirForReusableFolder("testLibrary-" + jarName), + jarName, + addSources, + allowKotlinSources, + extraOptions, + extraClasspath, + useJava9 + ) + } @JvmStatic @JvmOverloads fun compileJavaFilesLibraryToJar( - sourcesPath: String, - jarName: String, - addSources: Boolean = false, - extraOptions: List = emptyList(), - extraClasspath: List = emptyList() + sourcesPath: String, + jarName: String, + addSources: Boolean = false, + extraOptions: List = emptyList(), + extraClasspath: List = emptyList() ): File { return compileJvmLibraryToJar( - sourcesPath, jarName, addSources, - allowKotlinSources = false, - extraClasspath = extraClasspath, extraOptions = extraOptions + sourcesPath, jarName, addSources, + allowKotlinSources = false, + extraClasspath = extraClasspath, extraOptions = extraOptions ) } @JvmStatic @JvmOverloads fun compileLibraryToJar( - sourcesPath: String, - contentDir: File, - jarName: String, - addSources: Boolean = false, - allowKotlinSources: Boolean = true, - extraOptions: List = emptyList(), - extraClasspath: List = emptyList(), - useJava9: Boolean = false + sourcesPath: String, + contentDir: File, + jarName: String, + addSources: Boolean = false, + allowKotlinSources: Boolean = true, + extraOptions: List = emptyList(), + extraClasspath: List = emptyList(), + useJava9: Boolean = false ): File { val classesDir = File(contentDir, "classes") @@ -103,19 +111,18 @@ object MockLibraryUtil { // Probably no kotlin files were present, so dir might not have been created after kotlin compiler if (classesDir.exists()) { classpath += classesDir.path - } - else { + } else { FileUtil.createDirectory(classesDir) } val options = listOf( - "-classpath", classpath.joinToString(File.pathSeparator), - "-d", classesDir.path + "-classpath", classpath.joinToString(File.pathSeparator), + "-d", classesDir.path ) val compile = - if (useJava9) KotlinTestUtils::compileJavaFilesExternallyWithJava9 - else KotlinTestUtils::compileJavaFiles + if (useJava9) KotlinTestUtils::compileJavaFilesExternallyWithJava9 + else KotlinTestUtils::compileJavaFiles val success = compile(javaFiles, options) if (!success) { @@ -170,10 +177,10 @@ object MockLibraryUtil { @JvmStatic @JvmOverloads fun compileKotlin( - sourcesPath: String, - outDir: File, - extraOptions: List = emptyList(), - vararg extraClasspath: String + sourcesPath: String, + outDir: File, + extraOptions: List = emptyList(), + vararg extraClasspath: String ) { val classpath = mutableListOf() if (File(sourcesPath).isDirectory) { @@ -182,9 +189,9 @@ object MockLibraryUtil { classpath += extraClasspath val args = mutableListOf( - sourcesPath, - "-d", outDir.absolutePath, - "-classpath", classpath.joinToString(File.pathSeparator) + sourcesPath, + "-d", outDir.absolutePath, + "-classpath", classpath.joinToString(File.pathSeparator) ) + extraOptions runJvmCompiler(args) @@ -215,8 +222,8 @@ object MockLibraryUtil { @Synchronized private fun createCompilerClassLoader(): ClassLoader { return ClassPreloadingUtils.preloadClasses( - listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath), - Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null + listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath), + Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null ) } }