StdLib deprecations cleanup: length, size, indices and other collection operations.
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet
|
||||
val filePath = file.getPath()
|
||||
for (sourceDirPath in sourceDirPaths) {
|
||||
if (filePath.startsWith(sourceDirPath) && filePath.length() > sourceDirPath.length()) {
|
||||
val relativePath = filePath.substring(sourceDirPath.length + 1)
|
||||
val relativePath = filePath.substring(sourceDirPath.length() + 1)
|
||||
return relativePath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
val filePath = file.getPath()
|
||||
for (sourceDirPath in normalizedSourceDirs) {
|
||||
if (filePath.startsWith(sourceDirPath) && filePath.length() > sourceDirPath.length()) {
|
||||
return filePath.substring(sourceDirPath.length + 1)
|
||||
return filePath.substring(sourceDirPath.length() + 1)
|
||||
}
|
||||
}
|
||||
throw Exception("$file is not a child of any source roots $normalizedSourceDirs")
|
||||
@@ -483,7 +483,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
val lines = nodeText.trim().split('\n')
|
||||
// lets remove the /** ... * ... */ tokens
|
||||
val buffer = StringBuilder()
|
||||
val last = lines.size - 1
|
||||
val last = lines.size() - 1
|
||||
for (i in 0.rangeTo(last)) {
|
||||
var text = lines[i]
|
||||
text = text.trim()
|
||||
@@ -518,7 +518,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
// TODO we could default the test function name to match that of the
|
||||
// source code function if folks adopted a convention of naming the test method after the
|
||||
// method its acting as a demo/test for
|
||||
if (words.size > 1) {
|
||||
if (words.size() > 1) {
|
||||
val includeFile = words[0]
|
||||
val fnName = words[1]
|
||||
val content = findFunctionInclude(psiElement, includeFile, fnName)
|
||||
@@ -597,7 +597,7 @@ $highlight"""
|
||||
break
|
||||
}
|
||||
var count = 1
|
||||
for (i in 0.rangeTo(remaining.size - 1)) {
|
||||
for (i in 0.rangeTo(remaining.length() - 1)) {
|
||||
val ch = remaining[i]
|
||||
if (ch == '{') count ++
|
||||
else if (ch == '}') {
|
||||
@@ -619,7 +619,7 @@ $highlight"""
|
||||
|
||||
// lets try resolve the include name relative to this file
|
||||
val paths = relativeName.split('/')
|
||||
val size = paths.size
|
||||
val size = paths.size()
|
||||
for (i in 0.rangeTo(size - 2)) {
|
||||
val path = paths[i]
|
||||
if (path == ".") continue
|
||||
@@ -951,7 +951,7 @@ class KPackage(
|
||||
val nameAsRelativePath: String
|
||||
get() {
|
||||
val answer = namePaths.map{ ".." }.makeString("/")
|
||||
return if (answer.length == 0) "" else answer + "/"
|
||||
return if (answer.length() == 0) "" else answer + "/"
|
||||
}
|
||||
|
||||
override fun description(template: KDocTemplate): String {
|
||||
|
||||
+2
-2
@@ -190,10 +190,10 @@ Class ${klass.simpleName}</H2>
|
||||
|
||||
<P>""")
|
||||
println(klass.detailedDescription(this))
|
||||
if (klass.since.size > 0 || klass.authors.size > 0) {
|
||||
if (klass.since.length() > 0 || klass.authors.size() > 0) {
|
||||
println("""<P>
|
||||
<DL>""")
|
||||
if (klass.since.size > 0) {
|
||||
if (klass.since.length() > 0) {
|
||||
println("""<DT><B>Since:</B></DT>
|
||||
<DD>${klass.since}</DD>""")
|
||||
}
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ abstract class KDocTemplate() : TextTemplate() {
|
||||
if (cname.startsWith("kotlin.Function") && arguments.isNotEmpty()) {
|
||||
val rt = arguments.last()
|
||||
// TODO use drop()
|
||||
val rest = arguments.subList(0, arguments.size - 1).orEmpty()
|
||||
val rest = arguments.dropLast(1)
|
||||
"${typeArguments(rest, "(", ")", "()")} <A HREF=\"${href(c)}\" title=\"${c.kind} in ${c.packageName}\">-></a> ${link(rt)}"
|
||||
} else {
|
||||
val name = if (fullName) cname else c.simpleName
|
||||
|
||||
@@ -236,7 +236,7 @@ fun filtering(): List<GenericFunction> {
|
||||
returns(Strings) { "String" }
|
||||
body(Strings) {
|
||||
"""
|
||||
for (index in 0..length - 1)
|
||||
for (index in 0..length() - 1)
|
||||
if (!predicate(get(index))) {
|
||||
return substring(0, index)
|
||||
}
|
||||
@@ -357,7 +357,7 @@ fun filtering(): List<GenericFunction> {
|
||||
doc(Strings) { "Appends all characters matching the given [predicate] to the given [destination]." }
|
||||
body(Strings) {
|
||||
"""
|
||||
for (index in 0..length - 1) {
|
||||
for (index in 0..length() - 1) {
|
||||
val element = get(index)
|
||||
if (predicate(element)) destination.append(element)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user