From 6d4e48ab9a6af97d6b0545fdcd75731756799180 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 25 Jun 2015 23:46:18 +0300 Subject: [PATCH] Compiler&plugin deprecations cleanup: string operations. --- .../kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt | 2 +- .../org/jetbrains/kotlin/test/util/jetTestUtils.kt | 2 +- .../idea/intentions/OperatorToFunctionIntention.kt | 4 ++-- .../makeBackup/CreateIncrementalCompilationBackup.kt | 2 +- .../src/org/jetbrains/kotlin/idea/kdoc/KDocRenderer.kt | 2 +- .../org/jetbrains/kotlin/DataFlowValueRenderingTest.kt | 2 +- .../org/jetbrains/kotlin/j2k/DocCommentConverter.kt | 2 +- .../kotlin/jps/build/AbstractIncrementalJpsTest.kt | 10 +++++----- .../kotlin/js/resolve/diagnostics/jsRenderers.kt | 2 +- .../org/jetbrains/kotlin/template/HtmlTemplate.kt | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt index b70029394ff..bfd8906bf25 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt @@ -134,7 +134,7 @@ public class KotlinCoreEnvironment private constructor( })) sourceFiles.sortBy(object : Comparator { override fun compare(o1: JetFile, o2: JetFile): Int { - return o1.getVirtualFile().getPath().compareToIgnoreCase(o2.getVirtualFile().getPath()) + return o1.getVirtualFile().getPath().compareTo(o2.getVirtualFile().getPath(), ignoreCase = true) } }) diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/jetTestUtils.kt b/compiler/tests/org/jetbrains/kotlin/test/util/jetTestUtils.kt index 276d20542b9..41871c433fd 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/jetTestUtils.kt +++ b/compiler/tests/org/jetbrains/kotlin/test/util/jetTestUtils.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.* import java.io.File public fun String.trimTrailingWhitespacesAndAddNewlineAtEOF(): String = - this.split('\n').map { it.trimTrailing() }.joinToString(separator = "\n").let { + this.split('\n').map { it.trimEnd() }.joinToString(separator = "\n").let { result -> if (result.endsWith("\n")) result else result + "\n" } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt index 9683c17605e..5b9f0734b0e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt @@ -163,7 +163,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention
${title}:
") tags.forEach { - to.append("
${it.getSubjectName()} - ${markdownToHtml(it.getContent().trimLeading())}
") + to.append("
${it.getSubjectName()} - ${markdownToHtml(it.getContent().trimStart())}
") } to.append("\n") } diff --git a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt index de84ec14e89..c890df62468 100644 --- a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt @@ -49,7 +49,7 @@ public abstract class AbstractDataFlowValueRenderingTest: JetLightCodeInsightFix val info = expression.analyze().getDataFlowInfo(expression) val allValues = (info.getCompleteTypeInfo().keySet() + info.getCompleteNullabilityInfo().keySet()).toSet() - val actual = allValues.map { renderDataFlowValue(it) }.filterNotNull().sort().makeString("\n") + val actual = allValues.map { renderDataFlowValue(it) }.filterNotNull().sort().joinToString("\n") JetTestUtils.assertEqualsToFile(File(FileUtil.getNameWithoutExtension(fileName) + ".txt"), actual) } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt index 6340e357d1a..fda7c3d3498 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt @@ -71,7 +71,7 @@ object DocCommentConverter { private fun convertInlineDocTag(tag: PsiInlineDocTag) = when(tag.getName()) { "code", "literal" -> { val text = tag.getDataElements().map { it.getText() }.join("") - val escaped = StringUtil.escapeXml(text.trimLeading()) + val escaped = StringUtil.escapeXml(text.trimStart()) if (tag.getName() == "code") "$escaped" else escaped } diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index 05d889ce991..6ae59235b9c 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -170,17 +170,17 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { val fileName = file.getName() if (fileName.endsWith(newSuffix)) { - modifications.add(ModifyContent(getDirPrefix(fileName) + "/" + fileName.trimTrailing(newSuffix), file)) + modifications.add(ModifyContent(getDirPrefix(fileName) + "/" + fileName.removeSuffix(newSuffix), file)) } if (fileName.endsWith(deleteSuffix)) { - modifications.add(DeleteFile(getDirPrefix(fileName) + "/" + fileName.trimTrailing(deleteSuffix))) + modifications.add(DeleteFile(getDirPrefix(fileName) + "/" + fileName.removeSuffix(deleteSuffix))) } } return modifications } - val haveFilesWithoutNumbers = testDataDir.listFiles { it.getName().matches(".+\\.(new|delete)$") }?.isNotEmpty() ?: false - val haveFilesWithNumbers = testDataDir.listFiles { it.getName().matches(".+\\.(new|delete)\\.\\d+$") }?.isNotEmpty() ?: false + val haveFilesWithoutNumbers = testDataDir.listFiles { it.getName().matches(".+\\.(new|delete)$".toRegex()) }?.isNotEmpty() ?: false + val haveFilesWithNumbers = testDataDir.listFiles { it.getName().matches(".+\\.(new|delete)\\.\\d+$".toRegex()) }?.isNotEmpty() ?: false if (haveFilesWithoutNumbers && haveFilesWithNumbers) { fail("Bad test data format: files ending with both unnumbered and numbered \".new\"/\".delete\" were found") @@ -388,7 +388,7 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { override fun isEnabled(): Boolean = true override fun logLine(message: String?) { - logBuf.append(JetTestUtils.replaceHashWithStar(message!!.trimLeading(rootPath + "/"))).append('\n') + logBuf.append(JetTestUtils.replaceHashWithStar(message!!.removePrefix(rootPath + "/"))).append('\n') } } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt index 5d5d1619f55..2a43145c6a8 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt @@ -82,7 +82,7 @@ public fun String.underlineAsText(from: Int, to: Int): String { if (isEndOfLine(c.toInt())) { if (lineWasMarked) { - lines.appendln(marks.toString().trimTrailing()) + lines.appendln(marks.toString().trimEnd()) lineWasMarked = false } diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/HtmlTemplate.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/HtmlTemplate.kt index d2b8ace67c2..5039be00863 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/HtmlTemplate.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/HtmlTemplate.kt @@ -22,7 +22,7 @@ abstract class HtmlTemplate() : TextTemplate() { } else { // TODO: escape values - "<$tagName ${allAttributes.map { t -> "${t.first}='${t.second.escapeHtml()}'" }.makeString(" ")}>" + "<$tagName ${allAttributes.map { t -> "${t.first}='${t.second.escapeHtml()}'" }.joinToString(" ")}>" } ) content()