diff --git a/src/awesomewm.d.tl/visitors/module_dependencies.tl b/src/awesomewm.d.tl/visitors/module_dependencies.tl index 977ef1b..844744e 100644 --- a/src/awesomewm.d.tl/visitors/module_dependencies.tl +++ b/src/awesomewm.d.tl/visitors/module_dependencies.tl @@ -18,16 +18,45 @@ local function get_all_types_in_node(node: Node): { string } parameters_types or {}) end +local function replace_in_node_type(node: Node, old_type: string, new_type: string) + if node.parameters then + for _, v in ipairs(node.parameters) do + for i, t in ipairs(v.types) do + if t == old_type then + v.types[i] = new_type + end + end + end + end + + if node.types then + for i, t in ipairs(node.types) do + if t == old_type then + node.types[i] = new_type + end + end + end + + if node.return_types then + for i, t in ipairs(node.return_types) do + if t == old_type then + node.return_types[i] = new_type + end + end + end +end + local record Module_Dependencies visit: function(node: Node, mod: Node, d: Dag) end function Module_Dependencies.visit(node: Node, mod: Node, d: Dag) local all_types = get_all_types_in_node(node) - for _, v in ipairs(all_types) do - local dependency = d.modules[v] + for _, type_name in ipairs(all_types) do + local dependency = d.modules[type_name] or d.modules[utils.lowercase(type_name)] if dependency then mod.dependencies[dependency.name] = dependency.module_path + replace_in_node_type(node, dependency.module_path, dependency.name) end end end