@@ -88,6 +88,11 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
88
88
if repr == null then null .asInstanceOf [qctx.reflect.Symbol ] else repr.sym
89
89
private given qctx .type = qctx
90
90
91
+ lazy val srcPos = if owner == qctx.reflect.defn.RootClass then {
92
+ val sourceFile = dctx.args.rootDocPath.map(p => dotty.tools.dotc.util.SourceFile (dotty.tools.io.AbstractFile .getFile(p), scala.io.Codec .UTF8 ))
93
+ sourceFile.fold(dotty.tools.dotc.util.NoSourcePosition )(sf => dotty.tools.dotc.util.SourcePosition (sf, dotty.tools.dotc.util.Spans .NoSpan ))
94
+ } else owner.pos.get.asInstanceOf [dotty.tools.dotc.util.SrcPos ]
95
+
91
96
object SymOpsWithLinkCache extends SymOpsWithLinkCache
92
97
export SymOpsWithLinkCache ._
93
98
import SymOps ._
@@ -96,8 +101,7 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
96
101
if SchemeUri .matches(queryStr) then DocLink .ToURL (queryStr)
97
102
else QueryParser (queryStr).tryReadQuery() match
98
103
case Left (err) =>
99
- // TODO convert owner.pos to get to the comment, add stack trace
100
- report.warning(s " Unable to parse query ` $queryStr`: ${err.getMessage}" )
104
+ report.warning(s " Unable to parse query ` $queryStr`: ${err.getMessage}" , srcPos)
101
105
val msg = s " Unable to parse query: ${err.getMessage}"
102
106
DocLink .UnresolvedDRI (queryStr, msg)
103
107
case Right (query) =>
@@ -112,7 +116,8 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
112
116
val msg = s " $txt: $queryStr"
113
117
114
118
if (! summon[DocContext ].args.noLinkWarnings) then
115
- report.warning(msg, owner.pos.get.asInstanceOf [dotty.tools.dotc.util.SrcPos ])
119
+
120
+ report.warning(msg, srcPos)
116
121
117
122
DocLink .UnresolvedDRI (queryStr, txt)
118
123
0 commit comments