From: Jean Privat Date: Sat, 14 Mar 2015 05:13:53 +0000 (+0700) Subject: model: add `MDoc::location` X-Git-Tag: v0.7.3~26^2~12 X-Git-Url: http://nitlanguage.org model: add `MDoc::location` Signed-off-by: Jean Privat --- diff --git a/src/loader.nit b/src/loader.nit index 65e7c67..3bd8404 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -385,7 +385,7 @@ redef class ModelBuilder var readme = dirpath2.join_path("README.md") if not readme.file_exists then readme = dirpath2.join_path("README") if readme.file_exists then - var mdoc = new MDoc + var mdoc = new MDoc(new Location(new SourceFile.from_string(readme, ""),0,0,0,0)) var s = new FileReader.open(readme) while not s.eof do mdoc.content.add(s.read_line) diff --git a/src/model/mdoc.nit b/src/model/mdoc.nit index 2f8d045..4e8c565 100644 --- a/src/model/mdoc.nit +++ b/src/model/mdoc.nit @@ -16,6 +16,7 @@ module mdoc import model_base +import location # Structured documentation of a `MEntity` object class MDoc @@ -27,6 +28,9 @@ class MDoc # The entity where the documentation is originally attached to. # This gives some context to resolve identifiers or to run examples. var original_mentity: nullable MEntity = null is writable + + # The original location of the doc for error messages + var location: Location end redef class MEntity diff --git a/src/modelbuilder_base.nit b/src/modelbuilder_base.nit index 6cbcbef..9995338 100644 --- a/src/modelbuilder_base.nit +++ b/src/modelbuilder_base.nit @@ -375,7 +375,7 @@ redef class ADoc do var res = mdoc_cache if res != null then return res - res = new MDoc + res = new MDoc(location) for c in n_comment do var text = c.text if text.length < 2 then