StdLib deprecations cleanup: string operations.
This commit is contained in:
@@ -85,10 +85,10 @@ class JdbcTest {
|
|||||||
|
|
||||||
test fun formatCursor() {
|
test fun formatCursor() {
|
||||||
dataSource.query("select * from foo") {
|
dataSource.query("select * from foo") {
|
||||||
println(it.getColumnNames().toList().makeString("\t"))
|
println(it.getColumnNames().toList().joinToString("\t"))
|
||||||
|
|
||||||
for (row in it) {
|
for (row in it) {
|
||||||
println(it.getValues().makeString("\t"))
|
println(it.getValues().joinToString("\t"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public var Element.classes: String
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the element has the given CSS class style in its 'class' attribute */
|
/** Returns true if the element has the given CSS class style in its 'class' attribute */
|
||||||
public fun Element.hasClass(cssClass: String): Boolean = classes.matches("""(^|.*\s+)$cssClass($|\s+.*)""")
|
public fun Element.hasClass(cssClass: String): Boolean = classes.matches("""(^|.*\s+)$cssClass($|\s+.*)""".toRegex())
|
||||||
|
|
||||||
|
|
||||||
/** Returns the children of the element as a list */
|
/** Returns the children of the element as a list */
|
||||||
|
|||||||
+11
-11
@@ -144,7 +144,7 @@ abstract class KClassOrPackage(model: KModel, descriptor: DeclarationDescriptor)
|
|||||||
fun findFunction(expression: String): KFunction? {
|
fun findFunction(expression: String): KFunction? {
|
||||||
val idx = expression.indexOf('(')
|
val idx = expression.indexOf('(')
|
||||||
val name = if (idx > 0) expression.substring(0, idx) else expression
|
val name = if (idx > 0) expression.substring(0, idx) else expression
|
||||||
val postfix = if (idx > 0) expression.substring(idx).trimTrailing("()") else ""
|
val postfix = if (idx > 0) expression.substring(idx).removeSuffix("()") else ""
|
||||||
return functions.find{ it.name == name && it.parameterTypeText == postfix }
|
return functions.find{ it.name == name && it.parameterTypeText == postfix }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,8 +342,8 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
|||||||
canonicalFile.substring(rootDir.length())
|
canonicalFile.substring(rootDir.length())
|
||||||
else
|
else
|
||||||
canonicalFile
|
canonicalFile
|
||||||
val cleanRoot = root.trimTrailing("/")
|
val cleanRoot = root.removeSuffix("/")
|
||||||
val cleanPath = relativeFile.trimLeading("/")
|
val cleanPath = relativeFile.removePrefix("/")
|
||||||
return "$cleanRoot/$cleanPath$lineLinkText$sourceLine"
|
return "$cleanRoot/$cleanPath$lineLinkText$sourceLine"
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -488,14 +488,14 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
|||||||
var text = lines[i]
|
var text = lines[i]
|
||||||
text = text.trim()
|
text = text.trim()
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
text = text.trimLeading("/**").trimLeading("/*")
|
text = text.removePrefix("/**").removePrefix("/*")
|
||||||
} else {
|
} else {
|
||||||
buffer.append("\n")
|
buffer.append("\n")
|
||||||
}
|
}
|
||||||
if (i >= last) {
|
if (i >= last) {
|
||||||
text = text.trimTrailing("*/")
|
text = text.removeSuffix("*/")
|
||||||
} else if (i > 0) {
|
} else if (i > 0) {
|
||||||
text = text.trimLeading("* ")
|
text = text.removePrefix("* ")
|
||||||
if (text == "*") text = ""
|
if (text == "*") text = ""
|
||||||
}
|
}
|
||||||
text = processMacros(text, psiElement)
|
text = processMacros(text, psiElement)
|
||||||
@@ -830,7 +830,7 @@ abstract class KAnnotated(val model: KModel, val declarationDescriptor: Declarat
|
|||||||
val detailedText = detailedDescription(template)
|
val detailedText = detailedDescription(template)
|
||||||
val idx = detailedText.indexOf("</p>")
|
val idx = detailedText.indexOf("</p>")
|
||||||
return if (idx > 0) {
|
return if (idx > 0) {
|
||||||
detailedText.substring(0, idx).trimLeading("<p>")
|
detailedText.substring(0, idx).removePrefix("<p>")
|
||||||
} else {
|
} else {
|
||||||
detailedText
|
detailedText
|
||||||
}
|
}
|
||||||
@@ -950,7 +950,7 @@ class KPackage(
|
|||||||
/** Returns a relative path like ../.. for each path in the name */
|
/** Returns a relative path like ../.. for each path in the name */
|
||||||
val nameAsRelativePath: String
|
val nameAsRelativePath: String
|
||||||
get() {
|
get() {
|
||||||
val answer = namePaths.map{ ".." }.makeString("/")
|
val answer = namePaths.map{ ".." }.joinToString("/")
|
||||||
return if (answer.length() == 0) "" else answer + "/"
|
return if (answer.length() == 0) "" else answer + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,7 +958,7 @@ class KPackage(
|
|||||||
// lets see if we can find a custom summary
|
// lets see if we can find a custom summary
|
||||||
val text = model.config.packageSummaryText[name]
|
val text = model.config.packageSummaryText[name]
|
||||||
return if (text != null)
|
return if (text != null)
|
||||||
wikiConvert(text, template).trimLeading("<p>").trimTrailing("</p>")
|
wikiConvert(text, template).removePrefix("<p>").removeSuffix("</p>")
|
||||||
else
|
else
|
||||||
super<KClassOrPackage>.description(template)
|
super<KClassOrPackage>.description(template)
|
||||||
}
|
}
|
||||||
@@ -1104,7 +1104,7 @@ class KFunction(val descriptor: CallableDescriptor, val owner: KClassOrPackage,
|
|||||||
var exceptions: List<KClass> = listOf<KClass>(),
|
var exceptions: List<KClass> = listOf<KClass>(),
|
||||||
var annotations: List<KAnnotation> = listOf<KAnnotation>()): KAnnotated(owner.model, descriptor), Comparable<KFunction> {
|
var annotations: List<KAnnotation> = listOf<KAnnotation>()): KAnnotated(owner.model, descriptor), Comparable<KFunction> {
|
||||||
|
|
||||||
val parameterTypeText: String = parameters.map{ it.aType.name }.makeString(", ")
|
val parameterTypeText: String = parameters.map{ it.aType.name }.joinToString(", ")
|
||||||
|
|
||||||
override fun compareTo(other: KFunction): Int {
|
override fun compareTo(other: KFunction): Int {
|
||||||
var answer = name.compareTo(other.name)
|
var answer = name.compareTo(other.name)
|
||||||
@@ -1128,7 +1128,7 @@ class KFunction(val descriptor: CallableDescriptor, val owner: KClassOrPackage,
|
|||||||
|
|
||||||
/** Returns a list of generic type parameter names kinds like "A, I" */
|
/** Returns a list of generic type parameter names kinds like "A, I" */
|
||||||
val typeParametersText: String
|
val typeParametersText: String
|
||||||
get() = typeParameters.map{ it.name }.makeString(", ")
|
get() = typeParameters.map{ it.name }.joinToString(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
class KProperty(val owner: KClassOrPackage, val descriptor: PropertyDescriptor, val name: String,
|
class KProperty(val owner: KClassOrPackage, val descriptor: PropertyDescriptor, val name: String,
|
||||||
|
|||||||
+1
-1
@@ -149,7 +149,7 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun typeArguments(arguments: List<KType>, prefix: String = "<", postfix: String = ">", empty: String = ""): String {
|
open fun typeArguments(arguments: List<KType>, prefix: String = "<", postfix: String = ">", empty: String = ""): String {
|
||||||
val text = arguments.map<KType, String>() { link(it) }.makeString(", ")
|
val text = arguments.map<KType, String>() { link(it) }.joinToString(", ")
|
||||||
return if (text.length() == 0) empty else "$prefix$text$postfix"
|
return if (text.length() == 0) empty else "$prefix$text$postfix"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -119,7 +119,7 @@ abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
|||||||
println("""<PRE>""")
|
println("""<PRE>""")
|
||||||
println("""<FONT SIZE="-1">""")
|
println("""<FONT SIZE="-1">""")
|
||||||
printAnnotations(function.annotations)
|
printAnnotations(function.annotations)
|
||||||
print("""</FONT>${function.modifiers.makeString(" ")} $funKeyword""")
|
print("""</FONT>${function.modifiers.joinToString(" ")} $funKeyword""")
|
||||||
|
|
||||||
printTypeParameters(function, " ")
|
printTypeParameters(function, " ")
|
||||||
printReceiverType(function, " ", ".", " ")
|
printReceiverType(function, " ", ".", " ")
|
||||||
|
|||||||
+1
-1
@@ -169,7 +169,7 @@ public open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments
|
|||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|
||||||
private fun File.isJavaFile() = extension.equalsIgnoreCase(JavaFileType.INSTANCE.getDefaultExtension())
|
private fun File.isJavaFile() = extension.equals(JavaFileType.INSTANCE.getDefaultExtension(), ignoreCase = true)
|
||||||
|
|
||||||
override fun afterCompileHook(args: K2JVMCompilerArguments) {
|
override fun afterCompileHook(args: K2JVMCompilerArguments) {
|
||||||
getLogger().debug("Copying resulting files to classes")
|
getLogger().debug("Copying resulting files to classes")
|
||||||
|
|||||||
+3
-2
@@ -695,6 +695,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val pattern = "[\\.\\_\\-]".toRegex()
|
val pattern = "[\\.\\_\\-]".toRegex()
|
||||||
|
val digitsPattern = "\\d+".toRegex()
|
||||||
val part1 = v1.split(pattern)
|
val part1 = v1.split(pattern)
|
||||||
val part2 = v2.split(pattern)
|
val part2 = v2.split(pattern)
|
||||||
|
|
||||||
@@ -704,7 +705,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
|
|||||||
val p2 = part2[idx]
|
val p2 = part2[idx]
|
||||||
|
|
||||||
val cmp: Int
|
val cmp: Int
|
||||||
if (p1.matches("\\d+") && p2.matches("\\d+")) {
|
if (p1.matches(digitsPattern) && p2.matches(digitsPattern)) {
|
||||||
cmp = p1.toInt().compareTo(p2.toInt())
|
cmp = p1.toInt().compareTo(p2.toInt())
|
||||||
} else {
|
} else {
|
||||||
cmp = part1[idx].compareTo(part2[idx])
|
cmp = part1[idx].compareTo(part2[idx])
|
||||||
@@ -722,7 +723,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
|
|||||||
while (idx < parts.size()) {
|
while (idx < parts.size()) {
|
||||||
val p = parts[idx]
|
val p = parts[idx]
|
||||||
val cmp: Int
|
val cmp: Int
|
||||||
if (p.matches("\\d+")) {
|
if (p.matches(digitsPattern)) {
|
||||||
cmp = Integer(p).compareTo(0)
|
cmp = Integer(p).compareTo(0)
|
||||||
} else {
|
} else {
|
||||||
cmp = 1
|
cmp = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user