apply code cleanup; fix couple of deprecations manually
diff --git a/ant/src/dokka.kt b/ant/src/dokka.kt
index a6dccfb..882dbdb 100644
--- a/ant/src/dokka.kt
+++ b/ant/src/dokka.kt
@@ -89,7 +89,7 @@
         }
 
         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 cc19034..93470a4 100644
--- a/src/Formats/FormatService.kt
+++ b/src/Formats/FormatService.kt
@@ -8,7 +8,7 @@
  * * [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 246bd11..b990075 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 3b95a91..21fc9da 100644
--- a/src/Formats/KotlinWebsiteFormatService.kt
+++ b/src/Formats/KotlinWebsiteFormatService.kt
@@ -71,7 +71,7 @@
             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 9f25da5..6c7e882 100644
--- a/src/Formats/OutlineService.kt
+++ b/src/Formats/OutlineService.kt
@@ -5,7 +5,7 @@
 /**
  * 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 0ee3c88..a90c60b 100644
--- a/src/Formats/StructuredFormatService.kt
+++ b/src/Formats/StructuredFormatService.kt
@@ -6,7 +6,7 @@
 public data class FormatLink(val text: String, val href: String)
 
 enum class ListKind {
-    Ordered
+    Ordered,
     Unordered
 }
 
@@ -183,7 +183,7 @@
             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 d57210a..466ba30 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -62,7 +62,7 @@
                 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 @@
         "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 3dd5c00..01feef3 100644
--- a/src/Kotlin/ContentBuilder.kt
+++ b/src/Kotlin/ContentBuilder.kt
@@ -138,14 +138,14 @@
         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 b1a5903..4af53d8 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -96,7 +96,7 @@
         }
         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 @@
         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 8809a63..75675c6 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -56,7 +56,7 @@
         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 3508b48..c587335 100644
--- a/src/Languages/LanguageService.kt
+++ b/src/Languages/LanguageService.kt
@@ -3,10 +3,10 @@
 /**
  * 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 2c93ba8..7d0b8b5 100644
--- a/src/Locations/LocationService.kt
+++ b/src/Locations/LocationService.kt
@@ -2,7 +2,7 @@
 
 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 @@
  * * [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 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 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 30ec1fd..b442cd7 100644
--- a/src/Model/Content.kt
+++ b/src/Model/Content.kt
@@ -27,9 +27,9 @@
 }
 
 enum class IdentifierKind {
-    TypeName
-    ParameterName
-    AnnotationName
+    TypeName,
+    ParameterName,
+    AnnotationName,
     Other
 }
 
@@ -126,7 +126,7 @@
     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 6800abe..7f86218 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -64,43 +64,43 @@
     }
 
     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 b563b05..a61ac65 100644
--- a/src/Model/DocumentationReference.kt
+++ b/src/Model/DocumentationReference.kt
@@ -2,15 +2,15 @@
 
 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 4e2d2b1..4a0c22f 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -96,7 +96,7 @@
     DokkaConsoleLogger.report()
 }
 
-trait DokkaLogger {
+interface DokkaLogger {
     fun info(message: String)
     fun warn(message: String)
     fun error(message: String)
@@ -254,7 +254,7 @@
     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 171b5b9..165278f 100644
--- a/test/src/TestAPI.kt
+++ b/test/src/TestAPI.kt
@@ -58,7 +58,7 @@
     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 4aceb8e..867deec 100644
--- a/test/src/markdown/MarkdownTestRunner.kt
+++ b/test/src/markdown/MarkdownTestRunner.kt
@@ -18,7 +18,7 @@
 public open class MarkdownSpecification(val path: String, val processor: (String) -> String)
 
 
-trait MarkdownTest {
+interface MarkdownTest {
     fun description(): Description
 }
 
@@ -64,7 +64,7 @@
         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 @@
 
     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 @@
                 continue
             }
 
-            val head = line.takeWhile { it == '#' }.length
+            val head = line.takeWhile { it == '#' }.length()
             if (head == 0) {
                 index++
                 continue
@@ -117,9 +117,9 @@
                 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 @@
             }
             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 cef548c..3129bcc 100644
--- a/test/src/model/JavaTest.kt
+++ b/test/src/model/JavaTest.kt
@@ -12,7 +12,7 @@
             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)