[vala/1270-remove-static-codecontext-access: 44/44] Symbol: remove static access to CodeContext




commit d74d8bddde5a557167f68c436c0fa0373362126b
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Jan 2 20:47:39 2022 -0600

    Symbol: remove static access to CodeContext

 vala/valasymbol.vala | 84 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 70 insertions(+), 14 deletions(-)
---
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 7e8b4493a..4ae434734 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -452,59 +452,115 @@ public abstract class Vala.Symbol : CodeNode {
        }
 
        public virtual void add_namespace (Namespace ns) {
-               Report.error (ns.source_reference, "inner `%s' is not supported in `%s'", "namespace", 
get_full_name ());
+               if (context == null) {
+                       context = ns.context;
+               }
+
+               ns.context.report.log_error (ns.source_reference, "inner `%s' is not supported in `%s'", 
"namespace", get_full_name ());
        }
 
        public virtual void add_class (Class cl) {
-               Report.error (cl.source_reference, "inner `%s' types are not supported in `%s'", "class", 
get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (cl.source_reference, "inner `%s' types are not supported in `%s'", 
"class", get_full_name ());
        }
 
        public virtual void add_interface (Interface iface) {
-               Report.error (iface.source_reference, "inner `%s' types are not supported in `%s'", 
"interface", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (iface.source_reference, "inner `%s' types are not supported in 
`%s'", "interface", get_full_name ());
        }
 
        public virtual void add_struct (Struct st) {
-               Report.error (st.source_reference, "inner `%s' types are not supported in `%s'", "struct", 
get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (st.source_reference, "inner `%s' types are not supported in `%s'", 
"struct", get_full_name ());
        }
 
        public virtual void add_enum (Enum en) {
-               Report.error (en.source_reference, "inner `%s' types are not supported in `%s'", "enum", 
get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (en.source_reference, "inner `%s' types are not supported in `%s'", 
"enum", get_full_name ());
        }
 
        public virtual void add_error_domain (ErrorDomain edomain) {
-               Report.error (edomain.source_reference, "inner `%s' types are not supported in `%s'", 
"errordomain", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (edomain.source_reference, "inner `%s' types are not supported in 
`%s'", "errordomain", get_full_name ());
        }
 
        public virtual void add_delegate (Delegate d) {
-               Report.error (d.source_reference, "inner `%s' types are not supported in `%s'", "delegate", 
get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (d.source_reference, "inner `%s' types are not supported in `%s'", 
"delegate", get_full_name ());
        }
 
        public virtual void add_constant (Constant constant) {
-               Report.error (constant.source_reference, "constants are not allowed in `%s'", get_full_name 
());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (constant.source_reference, "constants are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_field (Field f) {
-               Report.error (f.source_reference, "fields are not allowed in `%s'", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (f.source_reference, "fields are not allowed in `%s'", get_full_name 
());
        }
 
        public virtual void add_method (Method m) {
-               Report.error (m.source_reference, "methods are not allowed in `%s'", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (m.source_reference, "methods are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_property (Property prop) {
-               Report.error (prop.source_reference, "properties are not allowed in `%s'", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (prop.source_reference, "properties are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_signal (Signal sig) {
-               Report.error (sig.source_reference, "signals are not allowed in `%s'", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (sig.source_reference, "signals are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_constructor (Constructor c) {
-               Report.error (c.source_reference, "constructors are not allowed in `%s'", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (c.source_reference, "constructors are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_destructor (Destructor d) {
-               Report.error (d.source_reference, "destructors are not allowed in `%s'", get_full_name ());
+               if (context == null) {
+                       context = traverse_for_context ();
+               }
+
+               context.report.log_error (d.source_reference, "destructors are not allowed in `%s'", 
get_full_name ());
        }
 
        public override string to_string () {


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