aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt3
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt19
2 files changed, 12 insertions, 10 deletions
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
}