[vala/1270-remove-static-codecontext-access] Symbol.add_namespace(): add instance context avoiding static access



commit dfbc8be749aa73118b27dfc2a40282a005b876aa
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Dec 29 16:40:33 2021 -0600

    Symbol.add_namespace(): add instance context avoiding static access

 vala/valagenieparser.vala   | 16 ++++++++--------
 vala/valagirparser.vala     |  2 +-
 vala/valanamespace.vala     |  4 ++--
 vala/valaparser.vala        | 14 +++++++-------
 vala/valasymbol.vala        |  4 ++--
 vapigen/valagidlparser.vala |  6 +++---
 6 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 87a125f22..71bfa1caf 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -2588,7 +2588,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                while (sym.inner != null) {
                        sym = sym.inner;
                        ns = new Namespace (sym.name, result.source_reference);
-                       ns.add_namespace ((Namespace) result);
+                       ns.add_namespace ((Namespace) result, context);
                        result = ns;
                }
                return result;
@@ -2598,7 +2598,7 @@ public class Vala.Genie.Parser : CodeVisitor {
 
                var sym = parse_declaration ((ns == context.root));
                if (sym is Namespace) {
-                       ns.add_namespace ((Namespace) sym);
+                       ns.add_namespace ((Namespace) sym, context);
                } else if (sym is Class) {
                        ns.add_class ((Class) sym);
                } else if (sym is Interface) {
@@ -2724,7 +2724,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        sym = sym.inner;
                        var ns = new Namespace (sym.name, cl.source_reference);
                        if (result is Namespace) {
-                               ns.add_namespace ((Namespace) result);
+                               ns.add_namespace ((Namespace) result, context);
                        } else {
                                ns.add_class ((Class) result);
                        }
@@ -3328,7 +3328,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        sym = sym.inner;
                        var ns = new Namespace (sym.name, st.source_reference);
                        if (result is Namespace) {
-                               ns.add_namespace ((Namespace) result);
+                               ns.add_namespace ((Namespace) result, context);
                        } else {
                                ns.add_struct ((Struct) result);
                        }
@@ -3397,7 +3397,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        sym = sym.inner;
                        var ns = new Namespace (sym.name, iface.source_reference);
                        if (result is Namespace) {
-                               ns.add_namespace ((Namespace) result);
+                               ns.add_namespace ((Namespace) result, context);
                        } else {
                                ns.add_interface ((Interface) result);
                        }
@@ -3484,7 +3484,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        sym = sym.inner;
                        var ns = new Namespace (sym.name, en.source_reference);
                        if (result is Namespace) {
-                               ns.add_namespace ((Namespace) result);
+                               ns.add_namespace ((Namespace) result, context);
                        } else {
                                ns.add_enum ((Enum) result);
                        }
@@ -3541,7 +3541,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        var ns = new Namespace (sym.name, ed.source_reference);
 
                        if (result is Namespace) {
-                               ns.add_namespace ((Namespace) result);
+                               ns.add_namespace ((Namespace) result, context);
                        } else {
                                ns.add_error_domain ((ErrorDomain) result);
                        }
@@ -3829,7 +3829,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        var ns = new Namespace (sym.name, d.source_reference);
 
                        if (result is Namespace) {
-                               ns.add_namespace ((Namespace) result);
+                               ns.add_namespace ((Namespace) result, context);
                        } else {
                                ns.add_delegate ((Delegate) result);
                        }
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index f99c64ceb..3ef7a22e7 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1589,7 +1589,7 @@ public class Vala.GirParser : CodeVisitor {
                        unowned Namespace ns = (Namespace) container;
 
                        if (sym is Namespace) {
-                               ns.add_namespace ((Namespace) sym);
+                               ns.add_namespace ((Namespace) sym, context);
                        } else if (sym is Class) {
                                ns.add_class ((Class) sym);
                        } else if (sym is Constant) {
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index d62babb63..bb46108d2 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -81,7 +81,7 @@ public class Vala.Namespace : Symbol {
         *
         * @param ns a namespace
         */
-       public override void add_namespace (Namespace ns) {
+       public override void add_namespace (Namespace ns, CodeContext context) {
                if (ns.owner == null) {
                        ns.source_reference.file.add_node (ns);
                }
@@ -97,7 +97,7 @@ public class Vala.Namespace : Symbol {
                                old_ns.add_using_directive (using_directive);
                        }
                        foreach (Namespace sub_ns in ns.get_namespaces ()) {
-                               old_ns.add_namespace (sub_ns);
+                               old_ns.add_namespace (sub_ns, context);
                        }
                        foreach (Class cl in ns.get_classes ()) {
                                old_ns.add_class (cl);
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 5d12d1d68..44b3f7b91 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2917,7 +2917,7 @@ public class Vala.Parser : CodeVisitor {
                        sym = sym.inner;
 
                        Symbol next = (sym != null ? new Namespace (sym.name, ns.source_reference) : parent);
-                       next.add_namespace ((Namespace) result);
+                       next.add_namespace ((Namespace) result, context);
                        result = next;
                }
        }
@@ -3050,7 +3050,7 @@ public class Vala.Parser : CodeVisitor {
 
                        Symbol next = (sym != null ? new Namespace (sym.name, cl.source_reference) : parent);
                        if (result is Namespace) {
-                               next.add_namespace ((Namespace) result);
+                               next.add_namespace ((Namespace) result, context);
                        } else if (!partial_reparse && cl.is_partial) {
                                PartialInfo info = { parent, begin, attrs };
                                partials += info;
@@ -3499,7 +3499,7 @@ public class Vala.Parser : CodeVisitor {
 
                        Symbol next = (sym != null ? new Namespace (sym.name, st.source_reference) : parent);
                        if (result is Namespace) {
-                               next.add_namespace ((Namespace) result);
+                               next.add_namespace ((Namespace) result, context);
                        } else {
                                next.add_struct ((Struct) result);
                        }
@@ -3542,7 +3542,7 @@ public class Vala.Parser : CodeVisitor {
 
                        Symbol next = (sym != null ? new Namespace (sym.name, iface.source_reference) : 
parent);
                        if (result is Namespace) {
-                               next.add_namespace ((Namespace) result);
+                               next.add_namespace ((Namespace) result, context);
                        } else {
                                next.add_interface ((Interface) result);
                        }
@@ -3609,7 +3609,7 @@ public class Vala.Parser : CodeVisitor {
 
                        Symbol next = (sym != null ? new Namespace (sym.name, en.source_reference) : parent);
                        if (result is Namespace) {
-                               next.add_namespace ((Namespace) result);
+                               next.add_namespace ((Namespace) result, context);
                        } else {
                                next.add_enum ((Enum) result);
                        }
@@ -3674,7 +3674,7 @@ public class Vala.Parser : CodeVisitor {
 
                        Symbol next = (sym != null ? new Namespace (sym.name, ed.source_reference) : parent);
                        if (result is Namespace) {
-                               next.add_namespace ((Namespace) result);
+                               next.add_namespace ((Namespace) result, context);
                        } else {
                                next.add_error_domain ((ErrorDomain) result);
                        }
@@ -3929,7 +3929,7 @@ public class Vala.Parser : CodeVisitor {
 
                        Symbol next = (sym != null ? new Namespace (sym.name, d.source_reference) : parent);
                        if (result is Namespace) {
-                               next.add_namespace ((Namespace) result);
+                               next.add_namespace ((Namespace) result, context);
                        } else {
                                next.add_delegate ((Delegate) result);
                        }
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 7e8b4493a..ad4e022b5 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -451,8 +451,8 @@ public abstract class Vala.Symbol : CodeNode {
                return true;
        }
 
-       public virtual void add_namespace (Namespace ns) {
-               Report.error (ns.source_reference, "inner `%s' is not supported in `%s'", "namespace", 
get_full_name ());
+       public virtual void add_namespace (Namespace ns, CodeContext context) {
+               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) {
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 007896ec4..df1cf7381 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -144,7 +144,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        foreach (weak IdlModule module in modules) {
                                var ns = parse_module (module);
                                if (ns != null) {
-                                       context.root.add_namespace (ns);
+                                       context.root.add_namespace (ns, context);
                                }
                        }
                } catch (MarkupError e) {
@@ -372,7 +372,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        unowned Namespace ns = (Namespace) container;
 
                        if (sym is Namespace) {
-                               ns.add_namespace ((Namespace) sym);
+                               ns.add_namespace ((Namespace) sym, context);
                        } else if (sym is Class) {
                                ns.add_class ((Class) sym);
                        } else if (sym is Constant) {
@@ -398,7 +398,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                }
                                ns.add_method (method);
                        } else if (sym is Namespace) {
-                               ns.add_namespace ((Namespace) sym);
+                               ns.add_namespace ((Namespace) sym, context);
                        } else if (sym is Struct) {
                                ns.add_struct ((Struct) sym);
                        }


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