diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-02-01 19:37:39 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-02-01 19:37:39 +0100 |
commit | e64c2e2d01cf30fe843fa3d4eff977c8b1ecccc4 (patch) | |
tree | 666cddc172ff213008e5841ace6dc62acf7e26b0 /doc-tool/src/dotty/tools/dottydoc/model | |
parent | dbbb7a3d9a668bbb8b62bec38f065f2444dacb91 (diff) | |
download | dotty-e64c2e2d01cf30fe843fa3d4eff977c8b1ecccc4.tar.gz dotty-e64c2e2d01cf30fe843fa3d4eff977c8b1ecccc4.tar.bz2 dotty-e64c2e2d01cf30fe843fa3d4eff977c8b1ecccc4.zip |
Add position based error reporting to dottydoc
Diffstat (limited to 'doc-tool/src/dotty/tools/dottydoc/model')
-rw-r--r-- | doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala | 7 | ||||
-rw-r--r-- | doc-tool/src/dotty/tools/dottydoc/model/comment/CommentParser.scala | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala index 1d98ff3f6..5b6c34de8 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala @@ -11,6 +11,8 @@ import com.vladsch.flexmark.ast.{ Node => MarkdownNode } import HtmlParsers._ import util.MemberLookup +import dotc.util.SourceFile + case class Comment ( body: String, short: String, @@ -73,7 +75,10 @@ trait MarkupConversion[T] extends MemberLookup { private def single(annot: String, xs: List[String], filter: Boolean = true)(implicit ctx: Context): Option[T] = (if (filter) filterEmpty(xs) else xs.map(stringToMarkup)) match { case x :: xs => - if (xs.nonEmpty) dottydoc.println(s"Only allowed to have a single annotation for $annot") + if (xs.nonEmpty) ctx.docbase.warn( + s"Only allowed to have a single annotation for $annot", + ent.symbol.sourcePosition(pos) + ) Some(x) case _ => None } diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentParser.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentParser.scala index 3c389af1e..b7a33a7ef 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentParser.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentParser.scala @@ -195,8 +195,14 @@ trait CommentParser extends util.MemberLookup { shortDescription = allTags(SimpleTagKey("shortDescription")) ) - for ((key, _) <- bodyTags) - dottydoc.println(s"$pos: Tag '@${key.name}' is not recognised") + for ((key, _) <- bodyTags) ctx.docbase.warn( + s"Tag '@${key.name}' is not recognised", + // FIXME: here the position is stretched out over the entire comment, + // with the point being at the very end. This ensures that the entire + // comment will be visible in error reporting. A more fine-grained + // reporting would be amazing here. + entity.symbol.sourcePosition(Position(pos.start, pos.end, pos.end)) + ) cmt } |