diff options
author | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-07-27 14:56:53 +0300 |
---|---|---|
committer | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-07-27 14:56:53 +0300 |
commit | 28685c67cff2ea5e2f11152c98fa732fc205f0d4 (patch) | |
tree | be57666af51c0cc029ce4a0bb80afa38901a09df /src/Model | |
parent | d874444314ba60427a21d01585a7e632fc6d4bb0 (diff) | |
download | dokka-28685c67cff2ea5e2f11152c98fa732fc205f0d4.tar.gz dokka-28685c67cff2ea5e2f11152c98fa732fc205f0d4.tar.bz2 dokka-28685c67cff2ea5e2f11152c98fa732fc205f0d4.zip |
SourcePosition shouldn't contain nulls
Diffstat (limited to 'src/Model')
-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? { |