diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-05-29 13:52:43 +0200 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-05-29 13:52:43 +0200 |
commit | 64414ce984bc86e09b8724adbd01f1cb2646c17e (patch) | |
tree | 802710da5009b0b86519cc7cde9cdb6685cc7c99 | |
parent | 2fc80c4aae0d2957b34b176b9a2a48cb5089f41c (diff) | |
download | dokka-64414ce984bc86e09b8724adbd01f1cb2646c17e.tar.gz dokka-64414ce984bc86e09b8724adbd01f1cb2646c17e.tar.bz2 dokka-64414ce984bc86e09b8724adbd01f1cb2646c17e.zip |
apply code cleanup; fix couple of deprecations manually
-rw-r--r-- | ant/src/dokka.kt | 2 | ||||
-rw-r--r-- | src/Formats/FormatService.kt | 2 | ||||
-rw-r--r-- | src/Formats/HtmlTemplateService.kt | 2 | ||||
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 2 | ||||
-rw-r--r-- | src/Formats/OutlineService.kt | 2 | ||||
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 4 | ||||
-rw-r--r-- | src/Java/JavaDocumentationBuilder.kt | 4 | ||||
-rw-r--r-- | src/Kotlin/ContentBuilder.kt | 4 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 4 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 2 | ||||
-rw-r--r-- | src/Languages/LanguageService.kt | 4 | ||||
-rw-r--r-- | src/Locations/LocationService.kt | 8 | ||||
-rw-r--r-- | src/Model/Content.kt | 8 | ||||
-rw-r--r-- | src/Model/DocumentationNode.kt | 56 | ||||
-rw-r--r-- | src/Model/DocumentationReference.kt | 18 | ||||
-rw-r--r-- | src/main.kt | 4 | ||||
-rw-r--r-- | test/src/TestAPI.kt | 2 | ||||
-rw-r--r-- | test/src/markdown/MarkdownTestRunner.kt | 18 | ||||
-rw-r--r-- | test/src/model/JavaTest.kt | 2 |
19 files changed, 74 insertions, 74 deletions
diff --git a/ant/src/dokka.kt b/ant/src/dokka.kt index a6dccfb7..882dbdb7 100644 --- a/ant/src/dokka.kt +++ b/ant/src/dokka.kt @@ -89,7 +89,7 @@ class DokkaAntTask(): Task() { } val url = javaClass<DokkaAntTask>().getResource("/org/jetbrains/dokka/ant/DokkaAntTask.class") - val jarRoot = url.getPath().substringBefore("!/").trimLeading("file:") + val jarRoot = url.getPath().substringBefore("!/").removePrefix("file:") val generator = DokkaGenerator( AntLogger(this), diff --git a/src/Formats/FormatService.kt b/src/Formats/FormatService.kt index cc190346..93470a4c 100644 --- a/src/Formats/FormatService.kt +++ b/src/Formats/FormatService.kt @@ -8,7 +8,7 @@ package org.jetbrains.dokka * * [MarkdownFormatService] – outputs documentation in Markdown format * * [TextFormatService] – outputs documentation in Text format */ -public trait FormatService { +public interface FormatService { /** Returns extension for output files */ val extension: String diff --git a/src/Formats/HtmlTemplateService.kt b/src/Formats/HtmlTemplateService.kt index 246bd11e..b9900757 100644 --- a/src/Formats/HtmlTemplateService.kt +++ b/src/Formats/HtmlTemplateService.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka -public trait HtmlTemplateService { +public interface HtmlTemplateService { fun appendHeader(to: StringBuilder, title: String?) fun appendFooter(to: StringBuilder) diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index 3b95a915..21fc9dae 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -71,7 +71,7 @@ public class KotlinWebsiteFormatService(locationService: LocationService, super.appendBlockCode(to, line, language) } else { to.append("<pre markdown=\"1\">") - to.append(line.trimLeading()) + to.append(line.trimStart()) to.append("</pre>") } } diff --git a/src/Formats/OutlineService.kt b/src/Formats/OutlineService.kt index 9f25da50..6c7e882e 100644 --- a/src/Formats/OutlineService.kt +++ b/src/Formats/OutlineService.kt @@ -5,7 +5,7 @@ import java.io.File /** * Service for building the outline of the package contents. */ -public trait OutlineFormatService { +public interface OutlineFormatService { fun getOutlineFileName(location: Location): File public fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder) diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 0ee3c888..a90c60b1 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.LanguageService.RenderMode public data class FormatLink(val text: String, val href: String) enum class ListKind { - Ordered + Ordered, Unordered } @@ -183,7 +183,7 @@ public abstract class StructuredFormatService(locationService: LocationService, val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull() if (deprecationValue != null) { to.append(formatStrong("Deprecated:")).append(" ") - appendLine(to, formatText(deprecationValue.name.trim("\""))) + appendLine(to, formatText(deprecationValue.name.removeSurrounding("\""))) appendLine(to) } else if (deprecation?.content != Content.Empty) { to.append(formatStrong("Deprecated:")).append(" ") diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index d57210ae..466ba304 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -62,7 +62,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, htmlBuilder.append(it.getText()) } } - val doc = Jsoup.parse(htmlBuilder.toString().trimLeading()) + val doc = Jsoup.parse(htmlBuilder.toString().trimStart()) doc.body().childNodes().forEach { convertHtmlNode(it) } @@ -142,7 +142,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, "code", "literal" -> { val text = StringBuilder() tag.getDataElements().forEach { text.append(it.getText()) } - val escaped = text.toString().trimLeading().htmlEscape() + val escaped = text.toString().trimStart().htmlEscape() if (tag.getName() == "code") "<code>$escaped</code>" else escaped } else -> tag.getText() diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index 3dd5c00e..01feef34 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -138,14 +138,14 @@ fun DocumentationBuilder.functionBody(descriptor: DeclarationDescriptor, functio is JetDeclarationWithBody -> ContentBlockCode().let() { val bodyExpression = psiElement.getBodyExpression() when (bodyExpression) { - is JetBlockExpression -> bodyExpression.getText().trim("{", "}") + is JetBlockExpression -> bodyExpression.getText().removeSurrounding("{", "}") else -> bodyExpression.getText() } } else -> psiElement.getText() } - val lines = text.trimTrailing().split("\n").filterNot { it.length() == 0 } + val lines = text.trimEnd().split("\n".toRegex()).toTypedArray().filterNot { it.length() == 0 } val indent = lines.map { it.takeWhile { it.isWhitespace() }.count() }.min() ?: 0 val finalText = lines.map { it.drop(indent) }.join("\n") return ContentBlockCode("kotlin").let() { it.append(ContentText(finalText)); it } diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index b1a5903e..4af53d88 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -96,7 +96,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } val name = descriptor.getName().asString() if (name == "equals" || name == "hashCode" || name == "toString") { - var deepestDescriptor = descriptor: CallableMemberDescriptor + var deepestDescriptor: CallableMemberDescriptor = descriptor while (!deepestDescriptor.getOverriddenDescriptors().isEmpty()) { deepestDescriptor = deepestDescriptor.getOverriddenDescriptors().first() } @@ -203,7 +203,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, return symbol } - fun KDocSection.getTags(): Array<KDocTag> = PsiTreeUtil.getChildrenOfType(this, javaClass<KDocTag>()) ?: array() + fun KDocSection.getTags(): Array<KDocTag> = PsiTreeUtil.getChildrenOfType(this, javaClass<KDocTag>()) ?: arrayOf() private fun MutableContent.addTagToSeeAlso(descriptor: DeclarationDescriptor, seeTag: KDocTag) { val subjectName = seeTag.getSubjectName() diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index 8809a630..75675c6f 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -56,7 +56,7 @@ class KotlinLanguageService : LanguageService { renderItem(nodes.first()) nodes.drop(1).forEach { if (noWrap) { - symbol(separator.trimTrailing(" ")) + symbol(separator.removeSuffix(" ")) nbsp() } else { symbol(separator) diff --git a/src/Languages/LanguageService.kt b/src/Languages/LanguageService.kt index 3508b48d..c587335a 100644 --- a/src/Languages/LanguageService.kt +++ b/src/Languages/LanguageService.kt @@ -3,10 +3,10 @@ package org.jetbrains.dokka /** * Provides facility for rendering [DocumentationNode] as a language-dependent declaration */ -trait LanguageService { +interface LanguageService { enum class RenderMode { /** Brief signature (used in a list of all members of the class). */ - SUMMARY + SUMMARY, /** Full signature (used in the page describing the member itself */ FULL } diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt index 2c93ba8f..7d0b8b56 100644 --- a/src/Locations/LocationService.kt +++ b/src/Locations/LocationService.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka import java.io.File -public trait Location { +public interface Location { val path: String get fun relativePathTo(other: Location, anchor: String? = null): String } @@ -41,7 +41,7 @@ public data class FileLocation(val file: File): Location { * * [SingleFolderLocationService] – all documentation is generated into single folder using fully qualified names * for file names. */ -public trait LocationService { +public interface LocationService { fun withExtension(newExtension: String) = this fun location(node: DocumentationNode): Location = location(node.path.map { it.name }, node.members.any()) @@ -54,7 +54,7 @@ public trait LocationService { } -public trait FileLocationService: LocationService { +public interface FileLocationService: LocationService { override fun location(node: DocumentationNode): FileLocation = location(node.path.map { it.name }, node.members.any()) override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation } @@ -62,7 +62,7 @@ public trait FileLocationService: LocationService { public fun identifierToFilename(path: String): String { val escaped = path.replace('<', '-').replace('>', '-') - val lowercase = escaped.replaceAll("[A-Z]") { matchResult -> "-" + matchResult.group().toLowerCase() } + val lowercase = escaped.replace("[A-Z]".toRegex()) { matchResult -> "-" + matchResult.value.toLowerCase() } return if (lowercase == "index") "--index--" else lowercase } diff --git a/src/Model/Content.kt b/src/Model/Content.kt index 30ec1fda..b442cd73 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -27,9 +27,9 @@ public open class ContentBlock() : ContentNode() { } enum class IdentifierKind { - TypeName - ParameterName - AnnotationName + TypeName, + ParameterName, + AnnotationName, Other } @@ -126,7 +126,7 @@ public open class Content(): ContentBlock() { public open val description: ContentNode get() = ContentEmpty fun findSectionByTag(tag: String): ContentSection? = - sections.firstOrNull { tag.equalsIgnoreCase(it.tag) } + sections.firstOrNull { tag.equals(it.tag, ignoreCase = true) } companion object { val Empty = Content() diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 6800abef..7f862183 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -64,43 +64,43 @@ public open class DocumentationNode(val name: String, } public enum class Kind { - Unknown + Unknown, - Package - Class - Interface - Enum - AnnotationClass - EnumItem - Object + Package, + Class, + Interface, + Enum, + AnnotationClass, + EnumItem, + Object, - Constructor - Function - Property + Constructor, + Function, + Property, - CompanionObjectProperty - CompanionObjectFunction + CompanionObjectProperty, + CompanionObjectFunction, - Parameter - Receiver - TypeParameter - Type - Supertype - UpperBound - LowerBound - Exception + Parameter, + Receiver, + TypeParameter, + Type, + Supertype, + UpperBound, + LowerBound, + Exception, - Modifier - NullabilityModifier + Modifier, + NullabilityModifier, - Module + Module, - ExternalClass - Annotation + ExternalClass, + Annotation, - Value + Value, - SourceUrl + SourceUrl, /** * A note which is rendered once on a page documenting a group of overloaded functions. diff --git a/src/Model/DocumentationReference.kt b/src/Model/DocumentationReference.kt index b563b058..a61ac65f 100644 --- a/src/Model/DocumentationReference.kt +++ b/src/Model/DocumentationReference.kt @@ -2,15 +2,15 @@ package org.jetbrains.dokka public data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReference.Kind) { public enum class Kind { - Owner - Member - Detail - Link - Extension - Inheritor - Override - Annotation - Deprecation + Owner, + Member, + Detail, + Link, + Extension, + Inheritor, + Override, + Annotation, + Deprecation, TopLevelPage } } diff --git a/src/main.kt b/src/main.kt index 4e2d2b11..4a0c22f8 100644 --- a/src/main.kt +++ b/src/main.kt @@ -96,7 +96,7 @@ public fun main(args: Array<String>) { DokkaConsoleLogger.report() } -trait DokkaLogger { +interface DokkaLogger { fun info(message: String) fun warn(message: String) fun error(message: String) @@ -254,7 +254,7 @@ fun KotlinCoreEnvironment.getJavaSourceFiles(): List<PsiJavaFile> { val result = arrayListOf<PsiJavaFile>() val localFileSystem = VirtualFileManager.getInstance().getFileSystem("file") sourceRoots.forEach { sourceRoot -> - sourceRoot.getAbsoluteFile().recurse { + sourceRoot.getAbsoluteFile().walkTopDown().forEach { val vFile = localFileSystem.findFileByPath(it.path) if (vFile != null) { val psiFile = PsiManager.getInstance(project).findFile(vFile) diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index 171b5b9d..165278f9 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -58,7 +58,7 @@ public fun verifyOutput(roots: Array<ContentRoot>, outputExtension: String, outp verifyModel(*roots) { val output = StringBuilder() outputGenerator(it, output) - val ext = outputExtension.trimLeading(".") + val ext = outputExtension.removePrefix(".") val path = roots.first().path val expectedOutput = File(path.replaceAfterLast(".", ext, path + "." + ext)).readText() assertEqualsIgnoringSeparators(expectedOutput, output.toString()) diff --git a/test/src/markdown/MarkdownTestRunner.kt b/test/src/markdown/MarkdownTestRunner.kt index 4aceb8e8..867deece 100644 --- a/test/src/markdown/MarkdownTestRunner.kt +++ b/test/src/markdown/MarkdownTestRunner.kt @@ -18,7 +18,7 @@ data class MarkdownTestUniqueId(val id: Int) : Serializable { public open class MarkdownSpecification(val path: String, val processor: (String) -> String) -trait MarkdownTest { +interface MarkdownTest { fun description(): Description } @@ -64,7 +64,7 @@ public open class MarkdownTestSection(val spec: MarkdownSpecification, val title when (child) { is MarkdownTestCase -> child.run(notifier) is MarkdownTestSection -> { - if (child.children.size == 0) { + if (child.children.size() == 0) { notifier.fireTestStarted(child.description()) notifier.fireTestFinished(child.description()) } else { @@ -83,18 +83,18 @@ public class MarkdownTestRunner(specificationClass: Class<MarkdownSpecification> private fun createTests(parent: MarkdownTestSection, lines: List<String>): Int { val testMark = lines.takeWhile { it.trim() != "." } - val testHtml = lines.drop(testMark.size).drop(1).takeWhile { it.trim() != "." } + val testHtml = lines.drop(testMark.size()).drop(1).takeWhile { it.trim() != "." } val markdown = testMark.join("\n", postfix = "\n", prefix = "\n") val html = testHtml.join("\n", postfix = "\n") val markdownTestCase = MarkdownTestCase(spec, markdown, html) parent.children.add(markdownTestCase) - return testMark.size + testHtml.size + 3 + return testMark.size() + testHtml.size() + 3 } private fun createSections(parent: MarkdownTestSection, lines: List<String>, level: Int): Int { var sectionNumber = 1 var index = 0 - while (index < lines.size) { + while (index < lines.size()) { val line = lines[index] if (line.trim() == ".") { @@ -102,7 +102,7 @@ public class MarkdownTestRunner(specificationClass: Class<MarkdownSpecification> continue } - val head = line.takeWhile { it == '#' }.length + val head = line.takeWhile { it == '#' }.length() if (head == 0) { index++ continue @@ -117,9 +117,9 @@ public class MarkdownTestRunner(specificationClass: Class<MarkdownSpecification> sectionNumber++ val section = MarkdownTestSection(spec, title) val lastIndex = createSections(section, lines.subList(index + 1, lines.lastIndex), level + 1) + index + 1 - if (section.children.size > 0) + if (section.children.size() > 0) parent.children.add(section) - val nextHead = lines[lastIndex].takeWhile { it == '#' }.length + val nextHead = lines[lastIndex].takeWhile { it == '#' }.length() if (nextHead < level) { return lastIndex } @@ -128,6 +128,6 @@ public class MarkdownTestRunner(specificationClass: Class<MarkdownSpecification> } index++ } - return lines.size + return lines.size() } }
\ No newline at end of file diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt index cef548c3..3129bcc0 100644 --- a/test/src/model/JavaTest.kt +++ b/test/src/model/JavaTest.kt @@ -12,7 +12,7 @@ public class JavaTest { with(cls.members.single()) { assertEquals("fn", name) assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("Summary for Function", content.summary.toTestString().trimTrailing()) + assertEquals("Summary for Function", content.summary.toTestString().trimEnd()) assertEquals(3, content.sections.size()) with(content.sections[0]) { assertEquals("Parameters", tag) |