[vala/1270-remove-static-codecontext-access] MarkupReader: use instance context's report log methods



commit 57485a8a76742b5a5209f7a6c93d85f0560f4131
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Dec 29 08:42:43 2021 -0600

    MarkupReader: use instance context's report log methods
    
    Avoids to use static Report methods.

 codegen/valagtkmodule.vala                        |  4 ++--
 libvaladoc/documentation/documentationparser.vala |  2 +-
 libvaladoc/importer/girdocumentationimporter.vala |  2 +-
 libvaladoc/importer/internalidregistrar.vala      |  6 ++++--
 vala/valagirparser.vala                           |  2 +-
 vala/valamarkupreader.vala                        | 10 ++++++----
 6 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/codegen/valagtkmodule.vala b/codegen/valagtkmodule.vala
index cf7d26b55..65f98c6b9 100644
--- a/codegen/valagtkmodule.vala
+++ b/codegen/valagtkmodule.vala
@@ -102,7 +102,7 @@ public class Vala.GtkModule : GSignalModule {
                                continue;
                        }
 
-                       MarkupReader reader = new MarkupReader (gresource);
+                       MarkupReader reader = new MarkupReader (context, gresource);
 
                        int state = 0;
                        string prefix = null;
@@ -148,7 +148,7 @@ public class Vala.GtkModule : GSignalModule {
                current_handler_to_signal_map = new HashMap<string, Signal>(str_hash, str_equal);
                current_child_to_class_map = new HashMap<string, Class>(str_hash, str_equal);
 
-               MarkupReader reader = new MarkupReader (ui_file);
+               MarkupReader reader = new MarkupReader (context, ui_file);
                Class current_class = null;
                Property? current_property = null;
                string? current_handler = null;
diff --git a/libvaladoc/documentation/documentationparser.vala 
b/libvaladoc/documentation/documentationparser.vala
index 0a5a0d04c..08d9a97ff 100644
--- a/libvaladoc/documentation/documentationparser.vala
+++ b/libvaladoc/documentation/documentationparser.vala
@@ -53,7 +53,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 
 
                metadata = new Vala.HashMap<Api.SourceFile, GirMetaData> ();
-               id_registrar = new Importer.InternalIdRegistrar ();
+               id_registrar = new Importer.InternalIdRegistrar (tree.context);
 
                init_valadoc_rules ();
        }
diff --git a/libvaladoc/importer/girdocumentationimporter.vala 
b/libvaladoc/importer/girdocumentationimporter.vala
index 057ab499b..2b70664d0 100644
--- a/libvaladoc/importer/girdocumentationimporter.vala
+++ b/libvaladoc/importer/girdocumentationimporter.vala
@@ -66,7 +66,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                var data = new Vala.SourceFile (tree.context, Vala.SourceFileType.PACKAGE, Path.get_basename 
(source_file));
                this.file = new Api.SourceFile (new Api.Package (Path.get_basename (source_file), true, null),
                                                                                source_file, null, data);
-               this.reader = new Vala.MarkupReader (source_file);
+               this.reader = new Vala.MarkupReader (tree.context, source_file);
 
                // xml prolog
                do {
diff --git a/libvaladoc/importer/internalidregistrar.vala b/libvaladoc/importer/internalidregistrar.vala
index c82241fc5..1457ff335 100644
--- a/libvaladoc/importer/internalidregistrar.vala
+++ b/libvaladoc/importer/internalidregistrar.vala
@@ -26,9 +26,11 @@ using Valadoc;
 public class Valadoc.Importer.InternalIdRegistrar {
        private Vala.HashMap<string, Api.Node> symbol_map;
        private Vala.HashMap<string, string> map;
+       private Vala.CodeContext context;
 
 
-       public InternalIdRegistrar () {
+       public InternalIdRegistrar (Vala.CodeContext context) {
+               this.context = context;
                map = new Vala.HashMap<string, string> (str_hash, str_equal);
                symbol_map = new Vala.HashMap<string, Api.Node> (str_hash, str_equal);
        }
@@ -53,7 +55,7 @@ public class Valadoc.Importer.InternalIdRegistrar {
                Vala.MarkupTokenType token;
 
                string base_path = index_sgml_online ?? Vala.CodeContext.realpath (filename);
-               var reader = new Vala.MarkupReader (filename);
+               var reader = new Vala.MarkupReader (context, filename);
 
                while ((token = reader.read_token (out begin, out end)) != Vala.MarkupTokenType.EOF) {
                        if (token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "ONLINE") {
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 3d426d5a4..f99c64ceb 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1481,7 +1481,7 @@ public class Vala.GirParser : CodeVisitor {
                cheader_filenames = null;
 
                this.current_source_file = source_file;
-               reader = new MarkupReader (source_file.filename);
+               reader = new MarkupReader (source_file.context, source_file.filename);
 
                // xml prolog
                do {
diff --git a/vala/valamarkupreader.vala b/vala/valamarkupreader.vala
index e8e858910..8adf08efe 100644
--- a/vala/valamarkupreader.vala
+++ b/vala/valamarkupreader.vala
@@ -33,6 +33,7 @@ public class Vala.MarkupReader {
        public string content { get; private set; }
 
        MappedFile mapped_file;
+       CodeContext context;
 
        char* begin;
        char* current;
@@ -44,7 +45,8 @@ public class Vala.MarkupReader {
        Map<string,string> attributes = new HashMap<string,string> (str_hash, str_equal);
        bool empty_element;
 
-       public MarkupReader (string filename) {
+       public MarkupReader (CodeContext context, string filename) {
+               this.context = context;
                this.filename = filename;
 
                try {
@@ -57,7 +59,7 @@ public class Vala.MarkupReader {
                        line = 1;
                        column = 1;
                } catch (FileError e) {
-                       Report.error (null, "Unable to map file `%s': %s", filename, e.message);
+                       context.report.log_error (null, "Unable to map file `%s': %s", filename, e.message);
                }
        }
 
@@ -101,7 +103,7 @@ public class Vala.MarkupReader {
                        if (u != (unichar) (-1)) {
                                current += u.to_utf8 (null);
                        } else {
-                               Report.error (null, "invalid UTF-8 character");
+                               context.report.log_error (null, "invalid UTF-8 character");
                        }
                }
                if (current == begin) {
@@ -232,7 +234,7 @@ public class Vala.MarkupReader {
                while (current < end && current[0] != end_char) {
                        unichar u = ((string) current).get_char_validated ((long) (end - current));
                        if (u == (unichar) (-1)) {
-                               Report.error (null, "invalid UTF-8 character");
+                               context.report.log_error (null, "invalid UTF-8 character");
                        } else if (u == '&') {
                                char* next_pos = current + u.to_utf8 (null);
                                if (((string) next_pos).has_prefix ("amp;")) {


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