diff options
Diffstat (limited to 'src/Model/SourceLinks.kt')
-rw-r--r-- | src/Model/SourceLinks.kt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Model/SourceLinks.kt b/src/Model/SourceLinks.kt index dff4b36b..4530518f 100644 --- a/src/Model/SourceLinks.kt +++ b/src/Model/SourceLinks.kt @@ -26,7 +26,21 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List<Sourc DocumentationReference.Kind.Detail); } - append(DocumentationNode("$path:${target?.lineNumber()}:${target?.columnNumber()}", Content.Empty, DocumentationNode.Kind.SourcePosition), DocumentationReference.Kind.Detail) + if (target != null) { + append(DocumentationNode(target.sourcePosition(), Content.Empty, DocumentationNode.Kind.SourcePosition), DocumentationReference.Kind.Detail) + } +} + +private fun PsiElement.sourcePosition(): String { + val path = containingFile.virtualFile.path + val lineNumber = lineNumber() + val columnNumber = columnNumber() + + return when { + lineNumber == null -> path + columnNumber == null -> "$path:$lineNumber" + else -> "$path:$lineNumber:$columnNumber" + } } fun PsiElement.lineNumber(): Int? { |