highlight: optionally print errors when highlighting
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 7 Sep 2017 15:16:52 +0000 (11:16 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 7 Sep 2017 16:08:46 +0000 (12:08 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/highlight.nit

index 3005aa7..f654c3e 100644 (file)
@@ -21,14 +21,16 @@ import pipeline
 import astutil
 import serialization
 
-# Fully process a content as a nit source file.
-fun hightlightcode(hl: HighlightVisitor, content: String): HLCode
+# Fully process `content` as a Nit source file.
+#
+# Set `print_errors = true` to print errors in the code to the console.
+fun hightlightcode(hl: HighlightVisitor, content: String, print_errors: nullable Bool): HLCode
 do
        # Prepare a stand-alone tool context
        var tc = new ToolContext
        tc.nit_dir = tc.locate_nit_dir # still use the common lib to have core
        tc.keep_going = true # no exit, obviously
-       tc.opt_warn.value = -1 # no output, obviously
+       if print_errors != true then tc.opt_warn.value = -1 # no output
 
        # Prepare an stand-alone model and model builder.
        # Unfortunately, models are enclosing and append-only.