[vala/1270-remove-static-codecontext-access] Symbol.add_method(): avoid use static code context



commit cbb8fee218fdca141bc738ad7f1b9c5de2689d75
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Dec 29 22:43:39 2021 -0600

    Symbol.add_method(): avoid use static code context

 vala/valaclass.vala            |  6 +++---
 vala/valaenum.vala             |  4 ++--
 vala/valaerrordomain.vala      |  4 ++--
 vala/valagenieparser.vala      | 10 +++++-----
 vala/valagirparser.vala        | 14 +++++++-------
 vala/valainterface.vala        |  6 +++---
 vala/valanamespace.vala        |  4 ++--
 vala/valaobjecttypesymbol.vala |  2 +-
 vala/valaparser.vala           |  8 ++++----
 vala/valastruct.vala           |  4 ++--
 vala/valasymbol.vala           |  4 ++--
 vapigen/valagidlparser.vala    | 34 +++++++++++++++++-----------------
 12 files changed, 50 insertions(+), 50 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 717e37242..80abbb093 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -273,7 +273,7 @@ public class Vala.Class : ObjectTypeSymbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                if (m.binding != MemberBinding.STATIC || m is CreationMethod) {
                        if (m.this_parameter != null) {
                                m.scope.remove (m.this_parameter.name);
@@ -297,7 +297,7 @@ public class Vala.Class : ObjectTypeSymbol {
                        unowned CreationMethod cm = (CreationMethod) m;
                        if (cm.class_name != null && cm.class_name != name) {
                                // class_name is null for constructors generated by GIdlParser
-                               Report.error (m.source_reference, "missing return type in method `%s.%s´", 
get_full_name (), cm.class_name);
+                               context.report.log_error (m.source_reference, "missing return type in method 
`%s.%s´", get_full_name (), cm.class_name);
                                m.error = true;
                                return;
                        }
@@ -313,7 +313,7 @@ public class Vala.Class : ObjectTypeSymbol {
                        }
                }
 
-               base.add_method (m);
+               base.add_method (m, context);
        }
 
        public HashMap<Method,Method> get_implicit_implementations () {
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index 642751caa..6dd9ac56a 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -72,9 +72,9 @@ public class Vala.Enum : TypeSymbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                if (m is CreationMethod) {
-                       Report.error (m.source_reference, "construction methods may only be declared within 
classes and structs");
+                       context.report.log_error (m.source_reference, "construction methods may only be 
declared within classes and structs");
 
                        m.error = true;
                        return;
diff --git a/vala/valaerrordomain.vala b/vala/valaerrordomain.vala
index 889d0b8ab..45bd581a5 100644
--- a/vala/valaerrordomain.vala
+++ b/vala/valaerrordomain.vala
@@ -55,9 +55,9 @@ public class Vala.ErrorDomain : TypeSymbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                if (m is CreationMethod) {
-                       Report.error (m.source_reference, "construction methods may only be declared within 
classes and structs");
+                       context.report.log_error (m.source_reference, "construction methods may only be 
declared within classes and structs");
 
                        m.error = true;
                        return;
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 935f08f99..26abc4cbf 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -2616,7 +2616,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        if (method.binding == MemberBinding.INSTANCE) {
                                method.binding = MemberBinding.STATIC;
                        }
-                       ns.add_method (method);
+                       ns.add_method (method, context);
                } else if (sym is Field) {
                        unowned Field field = (Field) sym;
                        if (field.binding == MemberBinding.INSTANCE) {
@@ -2716,7 +2716,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                        var m = new CreationMethod (cl.name, null, cl.source_reference);
                        m.access = (cl.is_abstract ? SymbolAccessibility.PROTECTED : 
SymbolAccessibility.PUBLIC);
                        m.body = new Block (cl.source_reference);
-                       cl.add_method (m);
+                       cl.add_method (m, context);
                }
 
                Symbol result = cl;
@@ -2744,7 +2744,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                } else if (sym is Delegate) {
                        cl.add_delegate ((Delegate) sym, context);
                } else if (sym is Method) {
-                       cl.add_method ((Method) sym);
+                       cl.add_method ((Method) sym, context);
                } else if (sym is Vala.Signal) {
                        cl.add_signal ((Vala.Signal) sym);
                } else if (sym is Field) {
@@ -3340,7 +3340,7 @@ public class Vala.Genie.Parser : CodeVisitor {
        void parse_struct_member (Struct st) throws ParseError {
                var sym = parse_declaration ();
                if (sym is Method) {
-                       st.add_method ((Method) sym);
+                       st.add_method ((Method) sym, context);
                } else if (sym is Field) {
                        st.add_field ((Field) sym, context);
                } else if (sym is Constant) {
@@ -3417,7 +3417,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                } else if (sym is Delegate) {
                        iface.add_delegate ((Delegate) sym, context);
                } else if (sym is Method) {
-                       iface.add_method ((Method) sym);
+                       iface.add_method ((Method) sym, context);
                } else if (sym is Vala.Signal) {
                        iface.add_signal ((Vala.Signal) sym);
                } else if (sym is Field) {
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 2400c681f..206d81cc9 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1342,7 +1342,7 @@ public class Vala.GirParser : CodeVisitor {
                                        var cm = new CreationMethod (null, null, cl.source_reference);
                                        cm.has_construct_function = false;
                                        cm.access = SymbolAccessibility.PROTECTED;
-                                       cl.add_method (cm);
+                                       cl.add_method (cm, parser.context);
                                }
                        }
 
@@ -1547,7 +1547,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (sym is Field) {
                                cl.add_field ((Field) sym, context);
                        } else if (sym is Method) {
-                               cl.add_method ((Method) sym);
+                               cl.add_method ((Method) sym, context);
                        } else if (sym is Property) {
                                cl.add_property ((Property) sym, context);
                        } else if (sym is Signal) {
@@ -1563,7 +1563,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (sym is Constant) {
                                en.add_constant ((Constant) sym, context);
                        } else if (sym is Method) {
-                               en.add_method ((Method) sym);
+                               en.add_method ((Method) sym, context);
                        }
                } else if (container is Interface) {
                        unowned Interface iface = (Interface) container;
@@ -1577,7 +1577,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (sym is Field) {
                                iface.add_field ((Field) sym, context);
                        } else if (sym is Method) {
-                               iface.add_method ((Method) sym);
+                               iface.add_method ((Method) sym, context);
                        } else if (sym is Property) {
                                iface.add_property ((Property) sym, context);
                        } else if (sym is Signal) {
@@ -1613,7 +1613,7 @@ public class Vala.GirParser : CodeVisitor {
                                if (method.binding == MemberBinding.INSTANCE) {
                                        method.binding = MemberBinding.STATIC;
                                }
-                               ns.add_method (method);
+                               ns.add_method (method, context);
                        } else if (sym is Struct) {
                                ns.add_struct ((Struct) sym, context);
                        }
@@ -1625,7 +1625,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (sym is Field) {
                                st.add_field ((Field) sym, context);
                        } else if (sym is Method) {
-                               st.add_method ((Method) sym);
+                               st.add_method ((Method) sym, context);
                        } else if (sym is Property) {
                                st.add_property ((Property) sym, context);
                        }
@@ -1635,7 +1635,7 @@ public class Vala.GirParser : CodeVisitor {
                        if (sym is ErrorCode) {
                                ed.add_code ((ErrorCode) sym);
                        } else if (sym is Method) {
-                               ed.add_method ((Method) sym);
+                               ed.add_method ((Method) sym, context);
                        }
                } else {
                        context.report.log_error (sym.source_reference, "impossible to add `%s' to container 
`%s'", sym.name, container.name);
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index e79c6e6f0..c0c53abb7 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -66,9 +66,9 @@ public class Vala.Interface : ObjectTypeSymbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                if (m is CreationMethod) {
-                       Report.error (m.source_reference, "construction methods may only be declared within 
classes and structs");
+                       context.report.log_error (m.source_reference, "construction methods may only be 
declared within classes and structs");
 
                        m.error = true;
                        return;
@@ -82,7 +82,7 @@ public class Vala.Interface : ObjectTypeSymbol {
                        m.result_var.is_result = true;
                }
 
-               base.add_method (m);
+               base.add_method (m, context);
        }
 
        /**
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index 1c0265ae7..31b1d965d 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -124,7 +124,7 @@ public class Vala.Namespace : Symbol {
                                old_ns.add_field (f, context);
                        }
                        foreach (Method m in ns.get_methods ()) {
-                               old_ns.add_method (m);
+                               old_ns.add_method (m, context);
                        }
                        foreach (Comment c in ns.get_comments ()) {
                                old_ns.add_comment (c);
@@ -388,7 +388,7 @@ public class Vala.Namespace : Symbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                // namespaces do not support private members
                if (m.access == SymbolAccessibility.PRIVATE) {
                        m.access = SymbolAccessibility.INTERNAL;
diff --git a/vala/valaobjecttypesymbol.vala b/vala/valaobjecttypesymbol.vala
index a84c1f3f6..37e055774 100644
--- a/vala/valaobjecttypesymbol.vala
+++ b/vala/valaobjecttypesymbol.vala
@@ -113,7 +113,7 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                methods.add (m);
                members.add (m);
 
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 73e6bdbfa..62fbbba6c 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2625,7 +2625,7 @@ public class Vala.Parser : CodeVisitor {
                        context.report.log_warning (method.source_reference, "main blocks are experimental");
                }
 
-               parent.add_method (method);
+               parent.add_method (method, context);
        }
 
        void parse_declaration (Symbol parent, bool root = false) throws ParseError {
@@ -3036,7 +3036,7 @@ public class Vala.Parser : CodeVisitor {
                        var m = new CreationMethod (cl.name, null, cl.source_reference);
                        m.access = (cl.is_abstract ? SymbolAccessibility.PROTECTED : 
SymbolAccessibility.PUBLIC);
                        m.body = new Block (cl.source_reference);
-                       cl.add_method (m);
+                       cl.add_method (m, context);
                }
 
                if (partial_reparse) {
@@ -3267,7 +3267,7 @@ public class Vala.Parser : CodeVisitor {
                        method.external = false;
                }
 
-               parent.add_method (method);
+               parent.add_method (method, context);
        }
 
        void parse_property_declaration (Symbol parent, List<Attribute>? attrs) throws ParseError {
@@ -3872,7 +3872,7 @@ public class Vala.Parser : CodeVisitor {
                        method.external = false;
                }
 
-               parent.add_method (method);
+               parent.add_method (method, context);
        }
 
        void parse_delegate_declaration (Symbol parent, List<Attribute>? attrs) throws ParseError {
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 32cdb7611..973572788 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -232,7 +232,7 @@ public class Vala.Struct : TypeSymbol {
         *
         * @param m a method
         */
-       public override void add_method (Method m) {
+       public override void add_method (Method m, CodeContext context) {
                if (m.binding == MemberBinding.INSTANCE || m is CreationMethod) {
                        m.this_parameter = new Parameter ("this", SemanticAnalyzer.get_this_type (m, this), 
m.source_reference);
                        m.scope.add (m.this_parameter.name, m.this_parameter);
@@ -250,7 +250,7 @@ public class Vala.Struct : TypeSymbol {
                        var cm = (CreationMethod) m;
                        if (cm.class_name != null && cm.class_name != name) {
                                // type_name is null for constructors generated by GIdlParser
-                               Report.error (m.source_reference, "missing return type in method `%s.%s´", 
get_full_name (), cm.class_name);
+                               context.report.log_error (m.source_reference, "missing return type in method 
`%s.%s´", get_full_name (), cm.class_name);
                                m.error = true;
                                return;
                        }
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index f7fd0ac37..c22593152 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -487,8 +487,8 @@ public abstract class Vala.Symbol : CodeNode {
                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 ());
+       public virtual void add_method (Method m, CodeContext context) {
+               context.report.log_error (m.source_reference, "methods are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_property (Property prop, CodeContext context) {
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index edcc3dfde..e6e51c6e6 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -330,7 +330,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        } else if (sym is Field) {
                                cl.add_field ((Field) sym, context);
                        } else if (sym is Method) {
-                               cl.add_method ((Method) sym);
+                               cl.add_method ((Method) sym, context);
                        } else if (sym is Property) {
                                cl.add_property ((Property) sym, context);
                        } else if (sym is Signal) {
@@ -346,7 +346,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        } else if (sym is Constant) {
                                en.add_constant ((Constant) sym, context);
                        } else if (sym is Method) {
-                               en.add_method ((Method) sym);
+                               en.add_method ((Method) sym, context);
                        }
                } else if (container is Interface) {
                        unowned Interface iface = (Interface) container;
@@ -360,7 +360,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        } else if (sym is Field) {
                                iface.add_field ((Field) sym, context);
                        } else if (sym is Method) {
-                               iface.add_method ((Method) sym);
+                               iface.add_method ((Method) sym, context);
                        } else if (sym is Property) {
                                iface.add_property ((Property) sym, context);
                        } else if (sym is Signal) {
@@ -396,7 +396,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                if (method.binding == MemberBinding.INSTANCE) {
                                        method.binding = MemberBinding.STATIC;
                                }
-                               ns.add_method (method);
+                               ns.add_method (method, context);
                        } else if (sym is Namespace) {
                                ns.add_namespace ((Namespace) sym, context);
                        } else if (sym is Struct) {
@@ -410,7 +410,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        } else if (sym is Field) {
                                st.add_field ((Field) sym, context);
                        } else if (sym is Method) {
-                               st.add_method ((Method) sym);
+                               st.add_method ((Method) sym, context);
                        } else if (sym is Property) {
                                st.add_property ((Property) sym, context);
                        }
@@ -858,7 +858,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                if (member.type == IdlNodeTypeId.FUNCTION) {
                                        var m = parse_function ((IdlNodeFunction) member);
                                        if (m != null) {
-                                               st.add_method (m);
+                                               st.add_method (m, context);
                                        }
                                } else if (member.type == IdlNodeTypeId.FIELD) {
                                        var f = parse_field ((IdlNodeField) member);
@@ -973,7 +973,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                                }
                                                var m = parse_function ((IdlNodeFunction) member);
                                                if (m != null) {
-                                                       cl.add_method (m);
+                                                       cl.add_method (m, context);
                                                }
                                        }
                                } else if (member.type == IdlNodeTypeId.FIELD) {
@@ -1053,7 +1053,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                if (member.type == IdlNodeTypeId.FUNCTION) {
                                        var m = parse_function ((IdlNodeFunction) member);
                                        if (m != null) {
-                                               st.add_method (m);
+                                               st.add_method (m, context);
                                        }
                                } else if (member.type == IdlNodeTypeId.FIELD) {
                                        var f = parse_field ((IdlNodeField) member);
@@ -1112,7 +1112,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                                }
                                                var m = parse_function ((IdlNodeFunction) member);
                                                if (m != null) {
-                                                       cl.add_method (m);
+                                                       cl.add_method (m, context);
                                                }
                                        }
                                } else if (member.type == IdlNodeTypeId.FIELD) {
@@ -1206,7 +1206,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                if (member.type == IdlNodeTypeId.FUNCTION) {
                                        var m = parse_function ((IdlNodeFunction) member);
                                        if (m != null) {
-                                               st.add_method (m);
+                                               st.add_method (m, context);
                                        }
                                } else if (member.type == IdlNodeTypeId.FIELD) {
                                        var f = parse_field ((IdlNodeField) member);
@@ -1303,7 +1303,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                                }
                                                var m = parse_function ((IdlNodeFunction) member);
                                                if (m != null) {
-                                                       cl.add_method (m);
+                                                       cl.add_method (m, context);
                                                }
                                        }
                                } else if (member.type == IdlNodeTypeId.FIELD) {
@@ -1432,7 +1432,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                        var m = new Method ("to_string", return_type, 
current_source_reference);
                                        m.access = SymbolAccessibility.PUBLIC;
                                        m.set_attribute_string ("CCode", "cname", eval(nv[1]));
-                                       en.add_method (m);
+                                       en.add_method (m, context);
                                } else if (nv[0] == "experimental") {
                                        if (eval (nv[1]) == "1") {
                                                en.set_attribute_bool ("Version", "experimental", true);
@@ -1615,13 +1615,13 @@ public class Vala.GIdlParser : CodeVisitor {
                                if (!current_type_vfunc_map.contains (member.name)) {
                                        var m = parse_function ((IdlNodeFunction) member);
                                        if (m != null) {
-                                               cl.add_method (m);
+                                               cl.add_method (m, context);
                                        }
                                }
                        } else if (member.type == IdlNodeTypeId.VFUNC) {
                                var m = parse_virtual ((IdlNodeVFunc) member, current_type_func_map.get 
(member.name));
                                if (m != null) {
-                                       cl.add_method (m);
+                                       cl.add_method (m, context);
                                }
                        } else if (member.type == IdlNodeTypeId.PROPERTY) {
                                var prop = parse_property ((IdlNodeProperty) member);
@@ -1674,7 +1674,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        var cm = new CreationMethod (null, null, cl.source_reference);
                        cm.has_construct_function = false;
                        cm.access = SymbolAccessibility.PROTECTED;
-                       cl.add_method (cm);
+                       cl.add_method (cm, context);
                }
 
                current_data_type = null;
@@ -1737,13 +1737,13 @@ public class Vala.GIdlParser : CodeVisitor {
                                if (!current_type_vfunc_map.contains (member.name)) {
                                        var m = parse_function ((IdlNodeFunction) member, true);
                                        if (m != null) {
-                                               iface.add_method (m);
+                                               iface.add_method (m, context);
                                        }
                                }
                        } else if (member.type == IdlNodeTypeId.VFUNC) {
                                var m = parse_virtual ((IdlNodeVFunc) member, current_type_func_map.get 
(member.name), true);
                                if (m != null) {
-                                       iface.add_method (m);
+                                       iface.add_method (m, context);
                                }
                        } else if (member.type == IdlNodeTypeId.PROPERTY) {
                                var prop = parse_property ((IdlNodeProperty) member);


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