@@ -88,6 +88,11 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
8888 if repr == null then null .asInstanceOf [qctx.reflect.Symbol ] else repr.sym
8989 private given qctx .type = qctx
9090
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+
9196 object SymOpsWithLinkCache extends SymOpsWithLinkCache
9297 export SymOpsWithLinkCache ._
9398 import SymOps ._
@@ -96,8 +101,7 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
96101 if SchemeUri .matches(queryStr) then DocLink .ToURL (queryStr)
97102 else QueryParser (queryStr).tryReadQuery() match
98103 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)
101105 val msg = s " Unable to parse query: ${err.getMessage}"
102106 DocLink .UnresolvedDRI (queryStr, msg)
103107 case Right (query) =>
@@ -112,7 +116,8 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
112116 val msg = s " $txt: $queryStr"
113117
114118 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)
116121
117122 DocLink .UnresolvedDRI (queryStr, txt)
118123
0 commit comments