aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt9
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt3
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt19
3 files changed, 17 insertions, 14 deletions
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index 9d75792c..5da41f29 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -122,15 +122,12 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
}
- private fun skipElement(element: Any) = skipElementByVisibility(element) || hasSuppressTag(element)
+ private fun skipElement(element: Any) = skipElementByVisibility(element) || hasSuppressDocTag(element)
private fun skipElementByVisibility(element: Any): Boolean =
!options.includeNonPublic && element is PsiModifierListOwner &&
(element.hasModifierProperty(PsiModifier.PRIVATE) || element.hasModifierProperty(PsiModifier.PACKAGE_LOCAL))
- private fun hasSuppressTag(element: Any) =
- element is PsiDocCommentOwner && element.docComment?.let { it.findTagByName("suppress") != null } ?: false
-
fun <T : Any> DocumentationNode.appendMembers(elements: Array<T>, buildFn: T.() -> DocumentationNode) =
appendChildren(elements, RefKind.Member, buildFn)
@@ -267,3 +264,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
return node
}
}
+
+fun hasSuppressDocTag(element: Any?) =
+ element is PsiDocCommentOwner && element.docComment?.let { it.findTagByName("suppress") != null } ?: false
+
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index c62f9cbf..3834dbf8 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
-import org.jetbrains.kotlin.resolve.source.PsiSourceElement
class DeclarationLinkResolver
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
@@ -62,7 +61,7 @@ class DeclarationLinkResolver
val containingClass = symbol.containingDeclaration as? JavaClassDescriptor ?: return null
val containingClassLink = buildJdkLink(containingClass)
if (containingClassLink != null) {
- val psi = (symbol.original.source as? PsiSourceElement)?.psi as? PsiMethod
+ val psi = symbol.sourcePsi() as? PsiMethod
if (psi != null) {
val params = psi.parameterList.parameters.joinToString { it.type.canonicalText }
return containingClassLink + "#" + symbol.name + "(" + params + ")"
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index e67f1aa1..f8df1f2e 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -679,9 +679,14 @@ fun AnnotationDescriptor.mustBeDocumented(): Boolean {
fun DeclarationDescriptor.isDocumentationSuppressed(): Boolean {
val doc = KDocFinder.findKDoc(this)
- return doc is KDocSection && doc.findTagByName("suppress") != null
+ if (doc is KDocSection && doc.findTagByName("suppress") != null) return true
+
+ return hasSuppressDocTag(sourcePsi())
}
+fun DeclarationDescriptor.sourcePsi() =
+ ((original as DeclarationDescriptorWithSource).source as? PsiSourceElement)?.psi
+
fun DeclarationDescriptor.isDeprecated(): Boolean = annotations.any {
DescriptorUtils.getFqName(it.type.constructor.declarationDescriptor!!).asString() == "kotlin.Deprecated"
} || (this is ConstructorDescriptor && containingDeclaration.isDeprecated())
@@ -760,13 +765,11 @@ fun DeclarationDescriptor.signatureWithSourceLocation(): String {
}
fun DeclarationDescriptor.sourceLocation(): String? {
- if (this is DeclarationDescriptorWithSource) {
- val psi = (this.source as? PsiSourceElement)?.getPsi()
- if (psi != null) {
- val fileName = psi.containingFile.name
- val lineNumber = psi.lineNumber()
- return if (lineNumber != null) "$fileName:$lineNumber" else fileName
- }
+ val psi = sourcePsi()
+ if (psi != null) {
+ val fileName = psi.containingFile.name
+ val lineNumber = psi.lineNumber()
+ return if (lineNumber != null) "$fileName:$lineNumber" else fileName
}
return null
}