[vala] valadoc: Create and register current Vala.CodeContext properly



commit ccf932f616dc60b856a37f28924b35e52d3d4e83
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Mar 13 19:30:32 2020 +0100

    valadoc: Create and register current Vala.CodeContext properly

 valadoc/tests/drivers/generic-api-test.vala | 4 ++++
 valadoc/treebuilder.vala                    | 5 +----
 valadoc/valadoc.vala                        | 4 ++++
 3 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/valadoc/tests/drivers/generic-api-test.vala b/valadoc/tests/drivers/generic-api-test.vala
index ced2bb6e6..79aa31d11 100644
--- a/valadoc/tests/drivers/generic-api-test.vala
+++ b/valadoc/tests/drivers/generic-api-test.vala
@@ -2900,6 +2900,8 @@ public static void test_driver () {
        settings.pkg_name = "out";
        settings.path = "out";
 
+       var context = new Vala.CodeContext ();
+       Vala.CodeContext.push (context);
 
        TreeBuilder builder = new TreeBuilder ();
        Api.Tree? doctree = builder.build (settings, reporter);
@@ -2945,6 +2947,8 @@ public static void test_driver () {
        assert (glib == true);
        assert (gobj == true);
        assert (test == true);
+
+       Vala.CodeContext.pop ();
 }
 
 
diff --git a/valadoc/treebuilder.vala b/valadoc/treebuilder.vala
index e2175ac4a..433938af2 100644
--- a/valadoc/treebuilder.vala
+++ b/valadoc/treebuilder.vala
@@ -984,8 +984,7 @@ public class Valadoc.TreeBuilder : Vala.CodeVisitor {
                this.settings = settings;
                this.reporter = reporter;
 
-               var context = new Vala.CodeContext ();
-               Vala.CodeContext.push (context);
+               var context = Vala.CodeContext.get ();
 
                this.tree = new Api.Tree (reporter, settings, context);
                create_valac_tree (context, settings);
@@ -1007,8 +1006,6 @@ public class Valadoc.TreeBuilder : Vala.CodeVisitor {
 
                context.accept(this);
 
-               Vala.CodeContext.pop ();
-
                return (reporter.errors == 0)? tree : null;
        }
 }
diff --git a/valadoc/valadoc.vala b/valadoc/valadoc.vala
index 2bb6558f9..87695b1e6 100644
--- a/valadoc/valadoc.vala
+++ b/valadoc/valadoc.vala
@@ -131,9 +131,11 @@ public class ValaDoc : Object {
        private static int quit (ErrorReporter reporter) {
                if (reporter.errors == 0 && (!fatal_warnings || reporter.warnings == 0)) {
                        stdout.printf ("Succeeded - %d warning(s)\n", reporter.warnings);
+                       Vala.CodeContext.pop ();
                        return 0;
                } else {
                        stdout.printf ("Failed: %d error(s), %d warning(s)\n", reporter.errors, 
reporter.warnings);
+                       Vala.CodeContext.pop ();
                        return 1;
                }
        }
@@ -231,6 +233,8 @@ public class ValaDoc : Object {
 
                settings.alternative_resource_dirs = alternative_resource_dirs;
 
+               var context = new Vala.CodeContext ();
+               Vala.CodeContext.push (context);
 
                // load plugins:
                Doclet? doclet = null;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]