From 0d251e79a39a84c98c90f058ac131b1aa8525281 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sat, 14 Mar 2015 12:13:53 +0700 Subject: [PATCH] model: add `MDoc::location` Signed-off-by: Jean Privat --- src/loader.nit | 2 +- src/model/mdoc.nit | 4 ++++ src/modelbuilder_base.nit | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) 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 -- 1.7.9.5