aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt3
-rw-r--r--core/src/main/kotlin/Formats/FormatService.kt2
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt4
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt2
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt4
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt2
-rw-r--r--core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt6
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt3
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt2
-rw-r--r--core/src/main/kotlin/Languages/JavaLanguageService.kt8
-rw-r--r--core/src/main/kotlin/Model/Content.kt8
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt8
-rw-r--r--core/src/main/kotlin/Model/PackageDocs.kt4
-rw-r--r--core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt6
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt4
-rw-r--r--core/src/main/kotlin/Utilities/ServiceLocator.kt5
-rw-r--r--core/src/main/kotlin/javadoc/docbase.kt4
-rw-r--r--core/src/test/kotlin/TestAPI.kt3
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt5
19 files changed, 38 insertions, 45 deletions
diff --git a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
index 319d85b1..f5fbf991 100644
--- a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
+++ b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
@@ -166,8 +166,7 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
private val sdk: Sdk = object : Sdk, RootProvider {
override fun getFiles(rootType: OrderRootType): Array<out VirtualFile> = classpathRoots
- .map { StandardFileSystems.local().findFileByPath(it.file.path) }
- .filterNotNull()
+ .mapNotNull { StandardFileSystems.local().findFileByPath(it.file.path) }
.toTypedArray()
override fun addRootSetChangedListener(p0: RootProvider.RootSetChangedListener) {
diff --git a/core/src/main/kotlin/Formats/FormatService.kt b/core/src/main/kotlin/Formats/FormatService.kt
index 63f25008..8f4855e3 100644
--- a/core/src/main/kotlin/Formats/FormatService.kt
+++ b/core/src/main/kotlin/Formats/FormatService.kt
@@ -22,7 +22,7 @@ interface FormatService {
}
interface FormattedOutputBuilder {
- /** Appends formatted content to [StringBuilder](to) using specified [location] */
+ /** Appends formatted content */
fun appendNodes(nodes: Iterable<DocumentationNode>)
}
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index e088b46d..82359454 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -229,9 +229,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
when (content) {
is ContentBlockSampleCode ->
- appendSampleBlockCode(content.language, content.importsBlock::appendBlockCodeContent, { content.appendBlockCodeContent() })
+ appendSampleBlockCode(content.language, content.importsBlock::appendBlockCodeContent) { content.appendBlockCodeContent() }
is ContentBlockCode ->
- appendBlockCode(content.language, { content.appendBlockCodeContent() })
+ appendBlockCode(content.language) { content.appendBlockCodeContent() }
}
}
is ContentHeading -> appendHeader(content.level) { appendContent(content.children) }
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index 98d56856..2eaf4af2 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -347,7 +347,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
fun hasSuppressDocTag(element: Any?): Boolean {
- val declaration = (element as? KtLightDeclaration<*, *>)?.kotlinOrigin as? KtDeclaration ?: return false
+ val declaration = (element as? KtLightDeclaration<*, *>)?.kotlinOrigin ?: return false
return PsiTreeUtil.findChildrenOfType(declaration.docComment, KDocTag::class.java).any { it.knownTag == KDocKnownTag.SUPPRESS }
}
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index 66db46d7..25a974a3 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -192,7 +192,7 @@ class JavadocParser(
return when {
element.hasAttr("docref") -> {
val docref = element.attr("docref")
- ContentNodeLazyLink(docref, { -> refGraph.lookupOrWarn(docref, logger) })
+ ContentNodeLazyLink(docref) { refGraph.lookupOrWarn(docref, logger)}
}
element.hasAttr("href") -> {
val href = element.attr("href")
@@ -235,7 +235,7 @@ class JavadocParser(
val linkNode =
ContentNodeLazyLink(
(tag.valueElement ?: linkElement).text
- ) { -> refGraph.lookupOrWarn(linkSignature!!, logger) }
+ ) { refGraph.lookupOrWarn(linkSignature!!, logger) }
linkNode.append(text)
linkNode
}
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index 32084eea..88494581 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -34,7 +34,7 @@ class DeclarationLinkResolver
val signature = elementSignatureProvider.signature(symbol)
val referencedAt = fromDescriptor.signatureWithSourceLocation()
- return ContentNodeLazyLink(href) { ->
+ return ContentNodeLazyLink(href) {
val target = refGraph.lookup(signature)
if (target == null) {
diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
index ddd8a32a..ce20aeec 100644
--- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
+++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
@@ -74,7 +74,7 @@ class DescriptorDocumentationParser
}
val tree = parseMarkdown(kdocText)
val linkMap = LinkMap.buildLinkMap(tree.node, kdocText)
- val content = buildContent(tree, LinkResolver(linkMap, { href -> linkResolver.resolveContentLink(contextDescriptor, href) }), inline)
+ val content = buildContent(tree, LinkResolver(linkMap) { href -> linkResolver.resolveContentLink(contextDescriptor, href) }, inline)
if (kdoc is KDocSection) {
val tags = kdoc.getTags()
tags.forEach {
@@ -87,7 +87,7 @@ class DescriptorDocumentationParser
val section = content.addSection(javadocSectionDisplayName(it.name), it.getSubjectName())
val sectionContent = it.getContent()
val markdownNode = parseMarkdown(sectionContent)
- buildInlineContentTo(markdownNode, section, LinkResolver(linkMap, { href -> linkResolver.resolveContentLink(contextDescriptor, href) }))
+ buildInlineContentTo(markdownNode, section, LinkResolver(linkMap) { href -> linkResolver.resolveContentLink(contextDescriptor, href) })
}
}
}
@@ -129,7 +129,7 @@ class DescriptorDocumentationParser
FqName.fromSegments(listOf("kotlin", "Any")), NoLookupLocation.FROM_IDE)
anyClassDescriptors.forEach {
val anyMethod = (it as ClassDescriptor).getMemberScope(listOf())
- .getDescriptorsFiltered(DescriptorKindFilter.FUNCTIONS, { it == descriptor.name })
+ .getDescriptorsFiltered(DescriptorKindFilter.FUNCTIONS) { it == descriptor.name }
.single()
val kdoc = anyMethod.findKDoc()
if (kdoc != null) {
diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
index 6e58f766..ee9d8c51 100644
--- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
@@ -42,8 +42,7 @@ class KotlinAsJavaDocumentationBuilder
fun PsiClass.isVisibleInDocumentation(): Boolean {
val origin: KtDeclaration = (this as KtLightElement<*, *>).kotlinOrigin as? KtDeclaration ?: return true
- return origin.hasModifier(KtTokens.INTERNAL_KEYWORD) != true &&
- origin.hasModifier(KtTokens.PRIVATE_KEYWORD) != true
+ return !origin.hasModifier(KtTokens.INTERNAL_KEYWORD) && !origin.hasModifier(KtTokens.PRIVATE_KEYWORD)
}
}
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index daa09cbf..7310610f 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -62,7 +62,7 @@ class KotlinLanguageService : CommonLanguageService() {
}
private fun List<DocumentationNode>.getReceiverKind(): ReceiverKind? {
- val qNames = map { it.getReceiverQName() }.filterNotNull()
+ val qNames = mapNotNull { it.getReceiverQName() }
if (qNames.size != size)
return null
diff --git a/core/src/main/kotlin/Languages/JavaLanguageService.kt b/core/src/main/kotlin/Languages/JavaLanguageService.kt
index 59bedd02..ad66123b 100644
--- a/core/src/main/kotlin/Languages/JavaLanguageService.kt
+++ b/core/src/main/kotlin/Languages/JavaLanguageService.kt
@@ -84,7 +84,7 @@ class JavaLanguageService : LanguageService {
return if (constraints.none())
node.name
else {
- node.name + " extends " + constraints.map { renderType(node) }.joinToString()
+ node.name + " extends " + constraints.joinToString { renderType(node) }
}
}
@@ -97,7 +97,7 @@ class JavaLanguageService : LanguageService {
val typeParameters = node.details(NodeKind.TypeParameter)
if (typeParameters.any()) {
append("<")
- append(typeParameters.map { renderTypeParameter(it) }.joinToString())
+ append(typeParameters.joinToString { renderTypeParameter(it) })
append("> ")
}
}.toString()
@@ -142,9 +142,9 @@ class JavaLanguageService : LanguageService {
val receiver = node.details(NodeKind.Receiver).singleOrNull()
append("(")
if (receiver != null)
- (listOf(receiver) + node.details(NodeKind.Parameter)).map { renderParameter(it) }.joinTo(this)
+ (listOf(receiver) + node.details(NodeKind.Parameter)).joinTo(this) { renderParameter(it) }
else
- node.details(NodeKind.Parameter).map { renderParameter(it) }.joinTo(this)
+ node.details(NodeKind.Parameter).joinTo(this) { renderParameter(it) }
append(")")
}.toString()
diff --git a/core/src/main/kotlin/Model/Content.kt b/core/src/main/kotlin/Model/Content.kt
index 8312b2e2..5530e1b4 100644
--- a/core/src/main/kotlin/Model/Content.kt
+++ b/core/src/main/kotlin/Model/Content.kt
@@ -171,10 +171,10 @@ class ContentSection(val tag: String, val subjectName: String?) : ContentBlock()
}
object ContentTags {
- val Description = "Description"
- val SeeAlso = "See Also"
- val Return = "Return"
- val Exceptions = "Exceptions"
+ const val Description = "Description"
+ const val SeeAlso = "See Also"
+ const val Return = "Return"
+ const val Exceptions = "Exceptions"
}
fun content(body: ContentBlock.() -> Unit): ContentBlock {
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 1ff14ff1..311b46e4 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -177,10 +177,10 @@ open class DocumentationNode(val name: String,
fun inheritedCompanionObjectMembers(kind: NodeKind): List<DocumentationNode> = inheritedCompanionObjectMembers.filter { it.kind == kind }
fun links(kind: NodeKind): List<DocumentationNode> = links.filter { it.kind == kind }
- fun detail(kind: NodeKind): DocumentationNode = details.filter { it.kind == kind }.single()
- fun detailOrNull(kind: NodeKind): DocumentationNode? = details.filter { it.kind == kind }.singleOrNull()
- fun member(kind: NodeKind): DocumentationNode = members.filter { it.kind == kind }.single()
- fun link(kind: NodeKind): DocumentationNode = links.filter { it.kind == kind }.single()
+ fun detail(kind: NodeKind): DocumentationNode = details.single { it.kind == kind }
+ fun detailOrNull(kind: NodeKind): DocumentationNode? = details.singleOrNull { it.kind == kind }
+ fun member(kind: NodeKind): DocumentationNode = members.single { it.kind == kind }
+ fun link(kind: NodeKind): DocumentationNode = links.single { it.kind == kind }
fun references(kind: RefKind): List<DocumentationReference> = references.filter { it.kind == kind }
diff --git a/core/src/main/kotlin/Model/PackageDocs.kt b/core/src/main/kotlin/Model/PackageDocs.kt
index 5b628914..cf6cd808 100644
--- a/core/src/main/kotlin/Model/PackageDocs.kt
+++ b/core/src/main/kotlin/Model/PackageDocs.kt
@@ -41,7 +41,7 @@ class PackageDocs
targetContent = findTargetContent(headingText.trimStart())
}
} else {
- buildContentTo(it, targetContent, LinkResolver(linkMap, { resolveContentLink(fileName, it, linkResolveContext) }))
+ buildContentTo(it, targetContent, LinkResolver(linkMap) { resolveContentLink(fileName, it, linkResolveContext) })
}
}
} else {
@@ -118,7 +118,7 @@ class PackageDocs
}
private fun findOrCreatePackageContent(packageName: String) =
- _packageContent.getOrPut(packageName) { -> MutableContent() }
+ _packageContent.getOrPut(packageName) { MutableContent() }
private fun resolveContentLink(fileName: String, href: String, linkResolveContext: List<PackageFragmentDescriptor>): ContentBlock {
if (linkResolver != null) {
diff --git a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
index f3f45c3f..da74495f 100644
--- a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
+++ b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
@@ -45,7 +45,7 @@ open class DefaultSampleProcessingService
val text = processSampleBody(psiElement).trim { it == '\n' || it == '\r' }.trimEnd()
val lines = text.split("\n")
val indent = lines.filter(String::isNotBlank).map { it.takeWhile(Char::isWhitespace).count() }.min() ?: 0
- val finalText = lines.map { it.drop(indent) }.joinToString("\n")
+ val finalText = lines.joinToString("\n") { it.drop(indent) }
return ContentBlockSampleCode(importsBlock = processImports(psiElement)).apply { append(ContentText(finalText)) }
}
@@ -81,9 +81,7 @@ open class DefaultSampleProcessingService
for (part in parts) {
// short name
val symbolName = Name.identifier(part)
- val partSymbol = currentScope.getContributedDescriptors(DescriptorKindFilter.ALL, { it == symbolName })
- .filter { it.name == symbolName }
- .firstOrNull()
+ val partSymbol = currentScope.getContributedDescriptors(DescriptorKindFilter.ALL) { it == symbolName }.firstOrNull { it.name == symbolName }
if (partSymbol == null) {
symbol = null
diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt
index c2e652b6..919ec30f 100644
--- a/core/src/main/kotlin/Utilities/DokkaModules.kt
+++ b/core/src/main/kotlin/Utilities/DokkaModules.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.Utilities
-import com.google.inject.*
+import com.google.inject.Binder
+import com.google.inject.Module
+import com.google.inject.TypeLiteral
import com.google.inject.binder.AnnotatedBindingBuilder
import com.google.inject.name.Names
import org.jetbrains.dokka.*
diff --git a/core/src/main/kotlin/Utilities/ServiceLocator.kt b/core/src/main/kotlin/Utilities/ServiceLocator.kt
index b2743c53..835cd34c 100644
--- a/core/src/main/kotlin/Utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/Utilities/ServiceLocator.kt
@@ -22,10 +22,7 @@ object ServiceLocator {
descriptor: ServiceDescriptor
): T {
val loadedClass = javaClass.classLoader.loadClass(descriptor.className)
- val constructor = loadedClass.constructors
- .filter { it.parameterTypes.isEmpty() }
- .firstOrNull()
- ?: throw ServiceLookupException("Class ${descriptor.className} has no corresponding constructor")
+ val constructor = loadedClass.constructors.firstOrNull { it.parameterTypes.isEmpty() } ?: throw ServiceLookupException("Class ${descriptor.className} has no corresponding constructor")
val implementationRawType: Any =
if (constructor.parameterTypes.isEmpty()) constructor.newInstance() else constructor.newInstance(constructor)
diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt
index 62d0ee26..0bf72ccf 100644
--- a/core/src/main/kotlin/javadoc/docbase.kt
+++ b/core/src/main/kotlin/javadoc/docbase.kt
@@ -481,9 +481,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
fun DocumentationNode.lookupSuperClasses(module: ModuleNodeAdapter) =
details(NodeKind.Supertype)
- .map { it.links.firstOrNull() }
- .map { module.allTypes[it?.qualifiedName()] }
- .filterNotNull()
+ .map { it.links.firstOrNull() }.mapNotNull { module.allTypes[it?.qualifiedName()] }
fun List<DocumentationNode>.collectAllTypesRecursively(): Map<String, DocumentationNode> {
val result = hashMapOf<String, DocumentationNode>()
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt
index 2277de78..4f9af761 100644
--- a/core/src/test/kotlin/TestAPI.kt
+++ b/core/src/test/kotlin/TestAPI.kt
@@ -6,7 +6,6 @@ import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtil
import com.intellij.rt.execution.junit.FileComparisonFailure
import org.jetbrains.dokka.*
-import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
import org.jetbrains.dokka.Utilities.DokkaAnalysisModule
import org.jetbrains.dokka.Utilities.DokkaRunModule
import org.jetbrains.kotlin.cli.common.config.ContentRoot
@@ -32,7 +31,7 @@ data class ModelConfig(
val defaultPlatforms: List<String> = emptyList(),
val noStdlibLink: Boolean = true,
val collectInheritedExtensionsFromLibraries: Boolean = false,
- val sourceLinks: List<SourceLinkDefinition> = emptyList()
+ val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition> = emptyList()
)
fun verifyModel(
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 64ada1d5..1c4dd258 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -149,8 +149,9 @@ class JavadocTest {
.find { it.name() == "some" }!!.parameters().first()
.type()
assertEquals("kotlin.jvm.functions.Function1", methodParamType.qualifiedTypeName())
- assertEquals("? super A, C", methodParamType.asParameterizedType().typeArguments()
- .map(Type::qualifiedTypeName).joinToString())
+ assertEquals("? super A, C",
+ methodParamType.asParameterizedType().typeArguments().joinToString(transform = Type::qualifiedTypeName)
+ )
}
}