diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-11 16:26:24 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-11 16:26:24 +0100 |
commit | f2b177ee27882e3f8d18af04e497fd0165a8e709 (patch) | |
tree | 309b2d04ce5efc232496c8bc72f99c8af79d8c69 /src/Model | |
parent | fa34f90549e572e73a5875309a19bc7c8922d7e2 (diff) | |
download | dokka-f2b177ee27882e3f8d18af04e497fd0165a8e709.tar.gz dokka-f2b177ee27882e3f8d18af04e497fd0165a8e709.tar.bz2 dokka-f2b177ee27882e3f8d18af04e497fd0165a8e709.zip |
show source locations for warnings
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/SourceLinks.kt | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Model/SourceLinks.kt b/src/Model/SourceLinks.kt index 556b813b..fc3293f2 100644 --- a/src/Model/SourceLinks.kt +++ b/src/Model/SourceLinks.kt @@ -18,10 +18,8 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List<Sourc if (linkDef != null) { var url = linkDef.url + path.substring(linkDef.path.length()) if (linkDef.lineSuffix != null) { - val doc = PsiDocumentManager.getInstance(psi!!.getProject()).getDocument(psi.getContainingFile()) - if (doc != null) { - // IJ uses 0-based line-numbers; external source browsers use 1-based - val line = doc.getLineNumber(target!!.getTextRange().getStartOffset()) + 1 + val line = target?.lineNumber() + if (line != null) { url += linkDef.lineSuffix + line.toString() } } @@ -29,3 +27,9 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List<Sourc DocumentationReference.Kind.Detail); } } + +fun PsiElement.lineNumber(): Int? { + val doc = PsiDocumentManager.getInstance(getProject()).getDocument(getContainingFile()) + // IJ uses 0-based line-numbers; external source browsers use 1-based + return doc?.getLineNumber(getTextRange().getStartOffset())?.plus(1) +} |