aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-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.kt6
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt4
-rw-r--r--core/src/main/kotlin/Generation/FileGenerator.kt1
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt4
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt12
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt6
-rw-r--r--core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt8
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt4
-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/DocumentationReference.kt6
-rw-r--r--core/src/main/kotlin/Model/PackageDocs.kt2
-rw-r--r--core/src/main/kotlin/Model/SourceLinks.kt2
-rw-r--r--core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt6
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt6
-rw-r--r--core/src/main/kotlin/Utilities/ServiceLocator.kt4
-rw-r--r--core/src/main/kotlin/javadoc/docbase.kt11
-rw-r--r--core/src/test/kotlin/TestAPI.kt1
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt1
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt1
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt1
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt4
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt1
-rw-r--r--core/src/test/kotlin/issues/IssuesTest.kt1
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt5
-rw-r--r--core/src/test/kotlin/model/FunctionTest.kt1
31 files changed, 52 insertions, 80 deletions
diff --git a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
index 4f6a7c76..1ad68643 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 952e14cf..bd27448a 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -174,9 +174,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) }
@@ -557,7 +557,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
if (node.kind == NodeKind.Module) {
appendHeader(3) { to.append("Index") }
node.members(NodeKind.AllTypes).singleOrNull()?.let { allTypes ->
- appendLink(link(node, allTypes, { "All Types" }))
+ appendLink(link(node, allTypes) { "All Types" })
}
}
}
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 09e5cedf..59b9dc5e 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -140,9 +140,7 @@ fun buildDocumentationModule(injector: Injector,
val analyzer = resolutionFacade.getFrontendService(LazyTopDownAnalyzer::class.java)
analyzer.analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, fragmentFiles)
- val fragments = fragmentFiles
- .map { resolutionFacade.resolveSession.getPackageFragment(it.packageFqName) }
- .filterNotNull()
+ val fragments = fragmentFiles.mapNotNull { resolutionFacade.resolveSession.getPackageFragment(it.packageFqName) }
.distinct()
val packageDocs = injector.getInstance(PackageDocs::class.java)
diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt
index b7c6cf63..aff07648 100644
--- a/core/src/main/kotlin/Generation/FileGenerator.kt
+++ b/core/src/main/kotlin/Generation/FileGenerator.kt
@@ -2,7 +2,6 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.google.inject.name.Named
-import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index cf2b0514..624c5fdc 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -18,7 +18,7 @@ fun getSignature(element: PsiElement?) = when(element) {
is PsiField -> element.containingClass!!.qualifiedName + "$" + element.name
is PsiMethod ->
element.containingClass!!.qualifiedName + "$" + element.name + "(" +
- element.parameterList.parameters.map { it.type.typeSignature() }.joinToString(",") + ")"
+ element.parameterList.parameters.joinToString(",") { it.type.typeSignature() } + ")"
else -> null
}
@@ -291,7 +291,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 c25f5813..ea3a5963 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -23,8 +23,7 @@ interface JavaDocumentationParser {
class JavadocParser(private val refGraph: NodeReferenceGraph,
private val logger: DokkaLogger) : JavaDocumentationParser {
override fun parseDocumentation(element: PsiNamedElement): JavadocParseResult {
- val docComment = (element as? PsiDocCommentOwner)?.docComment
- if (docComment == null) return JavadocParseResult.Empty
+ val docComment = (element as? PsiDocCommentOwner)?.docComment ?: return JavadocParseResult.Empty
val result = MutableContent()
var deprecatedContent: Content? = null
val para = ContentParagraph()
@@ -101,7 +100,7 @@ class JavadocParser(private val refGraph: NodeReferenceGraph,
private fun createLink(element: Element): ContentBlock {
val docref = element.attr("docref")
if (docref != null) {
- return ContentNodeLazyLink(docref, { -> refGraph.lookupOrWarn(docref, logger)})
+ return ContentNodeLazyLink(docref) { refGraph.lookupOrWarn(docref, logger)}
}
val href = element.attr("href")
if (href != null) {
@@ -112,15 +111,12 @@ class JavadocParser(private val refGraph: NodeReferenceGraph,
}
private fun MutableContent.convertSeeTag(tag: PsiDocTag) {
- val linkElement = tag.linkElement()
- if (linkElement == null) {
- return
- }
+ val linkElement = tag.linkElement() ?: return
val seeSection = findSectionByTag(ContentTags.SeeAlso) ?: addSection(ContentTags.SeeAlso, null)
val linkSignature = resolveLink(linkElement)
val text = ContentText(linkElement.text)
if (linkSignature != null) {
- val linkNode = ContentNodeLazyLink(tag.valueElement!!.text, { -> refGraph.lookupOrWarn(linkSignature, logger)})
+ val linkNode = ContentNodeLazyLink(tag.valueElement!!.text) { refGraph.lookupOrWarn(linkSignature, logger)}
linkNode.append(text)
seeSection.append(linkNode)
} else {
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index ffef399d..da2b7272 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -6,8 +6,6 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
-import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPrivateApi
-import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPublicApi
class DeclarationLinkResolver
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
@@ -37,14 +35,14 @@ class DeclarationLinkResolver
val signature = descriptorSignatureProvider.signature(symbol)
val referencedAt = fromDescriptor.signatureWithSourceLocation()
- return ContentNodeLazyLink(href, { ->
+ return ContentNodeLazyLink(href) {
val target = refGraph.lookup(signature)
if (target == null) {
logger.warn("Can't find node by signature $signature, referenced at $referencedAt")
}
target
- })
+ }
}
if ("/" in href) {
return ContentExternalLink(href)
diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
index 6e44df74..4d276b5a 100644
--- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
+++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
@@ -66,7 +66,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 {
@@ -79,7 +79,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) })
}
}
}
@@ -114,8 +114,8 @@ 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 })
- .single()
+ .getDescriptorsFiltered(DescriptorKindFilter.FUNCTIONS) { it == descriptor.name }
+ .single()
val kdoc = anyMethod.findKDoc()
if (kdoc != null) {
return kdoc
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 7b50fff5..9c726429 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -901,11 +901,11 @@ fun DocumentationNode.getParentForPackageMember(descriptor: DeclarationDescripto
if (extensionClassDescriptor != null && isExtensionForExternalClass(descriptor, extensionClassDescriptor, allFqNames) &&
!ErrorUtils.isError(extensionClassDescriptor)) {
val fqName = DescriptorUtils.getFqNameSafe(extensionClassDescriptor)
- return externalClassNodes.getOrPut(fqName, {
+ return externalClassNodes.getOrPut(fqName) {
val newNode = DocumentationNode(fqName.asString(), Content.Empty, NodeKind.ExternalClass)
append(newNode, RefKind.Member)
newNode
- })
+ }
}
}
return this
diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
index c7ed8292..21c1ae0f 100644
--- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
@@ -40,8 +40,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 f33c8c96..597002fb 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -55,7 +55,7 @@ class KotlinLanguageService : LanguageService {
}
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 1f5bbc83..ccb5bff3 100644
--- a/core/src/main/kotlin/Model/Content.kt
+++ b/core/src/main/kotlin/Model/Content.kt
@@ -135,10 +135,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 da85cabf..3ff1d127 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -130,10 +130,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 }
fun allReferences(): Set<DocumentationReference> = references
diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt
index a968f400..87e7ecea 100644
--- a/core/src/main/kotlin/Model/DocumentationReference.kt
+++ b/core/src/main/kotlin/Model/DocumentationReference.kt
@@ -45,15 +45,15 @@ class NodeReferenceGraph() {
}
fun link(fromNode: DocumentationNode, toSignature: String, kind: RefKind) {
- references.add(PendingDocumentationReference({ -> fromNode}, { -> nodeMap[toSignature]}, kind))
+ references.add(PendingDocumentationReference({ fromNode}, { nodeMap[toSignature]}, kind))
}
fun link(fromSignature: String, toNode: DocumentationNode, kind: RefKind) {
- references.add(PendingDocumentationReference({ -> nodeMap[fromSignature]}, { -> toNode}, kind))
+ references.add(PendingDocumentationReference({ nodeMap[fromSignature]}, { toNode}, kind))
}
fun link(fromSignature: String, toSignature: String, kind: RefKind) {
- references.add(PendingDocumentationReference({ -> nodeMap[fromSignature]}, { -> nodeMap[toSignature]}, kind))
+ references.add(PendingDocumentationReference({ nodeMap[fromSignature]}, { nodeMap[toSignature]}, kind))
}
fun lookup(signature: String) = nodeMap[signature]
diff --git a/core/src/main/kotlin/Model/PackageDocs.kt b/core/src/main/kotlin/Model/PackageDocs.kt
index bb8e98d1..7ba4bdad 100644
--- a/core/src/main/kotlin/Model/PackageDocs.kt
+++ b/core/src/main/kotlin/Model/PackageDocs.kt
@@ -33,7 +33,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 {
diff --git a/core/src/main/kotlin/Model/SourceLinks.kt b/core/src/main/kotlin/Model/SourceLinks.kt
index 2c75cfda..7575b2b3 100644
--- a/core/src/main/kotlin/Model/SourceLinks.kt
+++ b/core/src/main/kotlin/Model/SourceLinks.kt
@@ -23,7 +23,7 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List<Sourc
}
}
append(DocumentationNode(url, Content.Empty, NodeKind.SourceUrl),
- RefKind.Detail);
+ RefKind.Detail)
}
if (target != null) {
diff --git a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
index 116a5c02..ff11ca02 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 36704918..cead29c9 100644
--- a/core/src/main/kotlin/Utilities/DokkaModules.kt
+++ b/core/src/main/kotlin/Utilities/DokkaModules.kt
@@ -2,14 +2,12 @@ package org.jetbrains.dokka.Utilities
import com.google.inject.Binder
import com.google.inject.Module
-import com.google.inject.Provider
import com.google.inject.TypeLiteral
import com.google.inject.binder.AnnotatedBindingBuilder
+import com.google.inject.binder.ScopedBindingBuilder
import com.google.inject.name.Names
import org.jetbrains.dokka.*
import org.jetbrains.dokka.Formats.FormatDescriptor
-import org.jetbrains.dokka.Model.DescriptorSignatureProvider
-import org.jetbrains.dokka.Samples.SampleProcessingService
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import java.io.File
import kotlin.reflect.KClass
@@ -77,4 +75,4 @@ inline fun <reified T: Any> Binder.lazyBind(): Lazy<AnnotatedBindingBuilder<T>>
inline infix fun <reified T: Any, TKClass: KClass<out T>> Lazy<AnnotatedBindingBuilder<T>>.toOptional(kClass: TKClass?) =
kClass?.let { value toType it }
-inline infix fun <reified T: Any, TKClass: KClass<out T>> AnnotatedBindingBuilder<T>.toType(kClass: TKClass) = to(kClass.java)
+inline infix fun <reified T: Any, TKClass: KClass<out T>> AnnotatedBindingBuilder<T>.toType(kClass: TKClass): ScopedBindingBuilder = to(kClass.java)
diff --git a/core/src/main/kotlin/Utilities/ServiceLocator.kt b/core/src/main/kotlin/Utilities/ServiceLocator.kt
index 71bfd21b..6f2ebd0f 100644
--- a/core/src/main/kotlin/Utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/Utilities/ServiceLocator.kt
@@ -15,9 +15,7 @@ object ServiceLocator {
fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T {
val descriptor = lookupDescriptor(category, implementationName)
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 2a14c6ff..f33b1324 100644
--- a/core/src/main/kotlin/javadoc/docbase.kt
+++ b/core/src/main/kotlin/javadoc/docbase.kt
@@ -326,8 +326,9 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio
override fun thrownExceptionTypes(): Array<out Type> = emptyArray()
override fun receiverType(): Type? = receiverNode()?.let { receiver -> TypeAdapter(module, receiver) }
- override fun flatSignature(): String = node.details(NodeKind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")")
- override fun signature(): String = node.details(NodeKind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")") // TODO it should be FQ types
+ override fun flatSignature(): String = node.details(NodeKind.Parameter).joinToString(", ", "(", ")") { JavaLanguageService().renderType(it) }
+ override fun signature(): String =
+ node.details(NodeKind.Parameter).joinToString(", ", "(", ")") { JavaLanguageService().renderType(it) } // TODO it should be FQ types
override fun parameters(): Array<out Parameter> =
((receiverNode()?.let { receiver -> listOf<Parameter>(ReceiverParameterAdapter(module, receiver, this)) } ?: emptyList())
@@ -469,10 +470,8 @@ 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()
+ details(NodeKind.Supertype)
+ .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 aa3eff48..fa108b99 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.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
index 54c367fd..fd851414 100644
--- a/core/src/test/kotlin/format/HtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/HtmlFormatTest.kt
@@ -3,7 +3,6 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.config.KotlinSourceRoot
-import org.junit.Before
import org.junit.Test
import java.io.File
diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
index b971b54d..53c83de4 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
-import org.junit.Before
import org.junit.Ignore
import org.junit.Test
diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
index 49fa6d2f..8643d3e5 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
-import org.junit.Before
import org.junit.Test
class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() {
diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
index 453b1de8..00630e00 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
@@ -1,10 +1,6 @@
package org.jetbrains.dokka.tests
-import org.jetbrains.dokka.DokkaConsoleLogger
-import org.jetbrains.dokka.KotlinLanguageService
-import org.jetbrains.dokka.KotlinWebsiteRunnableSamplesFormatService
import org.junit.Ignore
-import org.junit.Test
@Ignore
class KotlinWebSiteRunnableSamplesFormatTest {
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 9e4c831d..e213315b 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
-import org.junit.Before
import org.junit.Test
class MarkdownFormatTest: FileGeneratorTestCase() {
diff --git a/core/src/test/kotlin/issues/IssuesTest.kt b/core/src/test/kotlin/issues/IssuesTest.kt
index 625d7e46..e8cb4d9c 100644
--- a/core/src/test/kotlin/issues/IssuesTest.kt
+++ b/core/src/test/kotlin/issues/IssuesTest.kt
@@ -2,7 +2,6 @@ package issues
import org.jetbrains.dokka.DocumentationNode
import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.tests.toTestString
import org.jetbrains.dokka.tests.verifyModel
import org.junit.Test
import kotlin.test.assertEquals
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 45c45aa4..aaeb7d00 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -120,8 +120,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)
+ )
}
}
diff --git a/core/src/test/kotlin/model/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt
index 32910682..8a3f69d8 100644
--- a/core/src/test/kotlin/model/FunctionTest.kt
+++ b/core/src/test/kotlin/model/FunctionTest.kt
@@ -5,7 +5,6 @@ import org.jetbrains.dokka.NodeKind
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
-import kotlin.test.assertNotNull
class FunctionTest {
@Test fun function() {