aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers/pages
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2022-10-26 21:07:09 +0300
committerGitHub <noreply@github.com>2022-10-26 21:07:09 +0300
commitd1b24984fdf6d2f383697b557086c62c94e4eee0 (patch)
tree037cd0ed9deafd2a174535458f3b5c0ab9b1635b /plugins/base/src/main/kotlin/transformers/pages
parent4c122a4d46f9f100e1508b602942c571067a1d88 (diff)
downloaddokka-d1b24984fdf6d2f383697b557086c62c94e4eee0.tar.gz
dokka-d1b24984fdf6d2f383697b557086c62c94e4eee0.tar.bz2
dokka-d1b24984fdf6d2f383697b557086c62c94e4eee0.zip
Fix source link to the line with name (#2724)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/pages')
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index 0bb4a732..27428fc6 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -2,6 +2,7 @@ package org.jetbrains.dokka.base.transformers.pages.sourcelinks
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiIdentifier
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.analysis.DescriptorDocumentableSource
@@ -16,6 +17,8 @@ import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
+import org.jetbrains.kotlin.lexer.KtTokens
+import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.utils.addToStdlib.cast
import java.io.File
@@ -92,8 +95,10 @@ class SourceLinksTransformer(val context: DokkaContext) : PageTransformer {
}
private fun PsiElement.lineNumber(): Int? {
+ val ktIdentifierTextRange = this.node?.findChildByType(KtTokens.IDENTIFIER)?.textRange
+ val javaIdentifierTextRange = this.getChildOfType<PsiIdentifier>()?.textRange
// synthetic and some light methods might return null
- val textRange = textRange ?: return null
+ val textRange = ktIdentifierTextRange ?: javaIdentifierTextRange ?: textRange ?: return null
val doc = PsiDocumentManager.getInstance(project).getDocument(containingFile)
// IJ uses 0-based line-numbers; external source browsers use 1-based