Compiler&plugin deprecations cleanup: string operations.
This commit is contained in:
@@ -134,7 +134,7 @@ public class KotlinCoreEnvironment private constructor(
|
||||
}))
|
||||
sourceFiles.sortBy(object : Comparator<JetFile> {
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -163,7 +163,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
||||
val parent = element.getParent()
|
||||
val array = element.getArrayExpression()!!.getText()
|
||||
val indices = element.getIndicesNode()
|
||||
val indicesText = indices.getText()?.trim("[","]") ?: throw AssertionError("Indices node of ArrayExpression shouldn't be null: JetArrayAccessExpression = ${element.getText()}")
|
||||
val indicesText = indices.getText()?.removeSurrounding("[","]") ?: throw AssertionError("Indices node of ArrayExpression shouldn't be null: JetArrayAccessExpression = ${element.getText()}")
|
||||
|
||||
val transformation : String
|
||||
val replaced : JetElement
|
||||
@@ -185,7 +185,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
||||
private fun convertCall(element: JetCallExpression): JetExpression {
|
||||
val callee = element.getCalleeExpression()!!
|
||||
val arguments = element.getValueArgumentList()
|
||||
val argumentString = arguments?.getText()?.trim("(", ")")
|
||||
val argumentString = arguments?.getText()?.removeSurrounding("(", ")")
|
||||
val funcLitArgs = element.getFunctionLiteralArguments()
|
||||
val calleeText = callee.getText()
|
||||
val transformation = "$calleeText.${OperatorConventions.INVOKE.asString()}" +
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb
|
||||
for (rev in revisions) {
|
||||
val label = rev.getLabel()
|
||||
if (label != null && label.startsWith(HISTORY_LABEL_PREFIX)) {
|
||||
val patchFile = File(patchesDir, label.trimLeading(HISTORY_LABEL_PREFIX) + ".patch")
|
||||
val patchFile = File(patchesDir, label.removePrefix(HISTORY_LABEL_PREFIX) + ".patch")
|
||||
|
||||
indicator.setText("Creating patch $patchFile")
|
||||
indicator.setFraction(PATCHES_FRACTION * patchesCreated / PATCHES_TO_CREATE)
|
||||
|
||||
@@ -72,7 +72,7 @@ object KDocRenderer {
|
||||
}
|
||||
to.append("<dl><dt><b>${title}:</b></dt>")
|
||||
tags.forEach {
|
||||
to.append("<dd><code>${it.getSubjectName()}</code> - ${markdownToHtml(it.getContent().trimLeading())}</dd>")
|
||||
to.append("<dd><code>${it.getSubjectName()}</code> - ${markdownToHtml(it.getContent().trimStart())}</dd>")
|
||||
}
|
||||
to.append("</dl>\n")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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") "<code>$escaped</code>" else escaped
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user