From 915e089e000d9510dbbd2865321fb9d87b366d8f Mon Sep 17 00:00:00 2001 From: Aire-One Date: Tue, 2 Jan 2024 17:02:54 +0100 Subject: [PATCH] fix(visitor): module_dependencies DAG find_module --- src/awesomewmdtl/dag.tl | 24 +++++++++---------- .../visitors/module_dependencies.tl | 17 ++++++++++++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/awesomewmdtl/dag.tl b/src/awesomewmdtl/dag.tl index 20be5d5..e4c0217 100644 --- a/src/awesomewmdtl/dag.tl +++ b/src/awesomewmdtl/dag.tl @@ -78,24 +78,22 @@ end local function find_module(dag: Dag, module_path: string): Node local current_path = "" + local current: Node = { children = dag.modules } for breadcrumb in module_path:gmatch("([^%.]+)") do current_path = current_path == "" and breadcrumb or current_path .. "." .. breadcrumb - local current: Node = nil - - if current_path == module_path then - return current - end - - for _, n in ipairs(dag.modules) do - if n.module_path == current_path then - current = n - break + for _, child in ipairs(current.children) do + if child.module_path == module_path then + return child + end + if child.module_path == current_path then + current = child + goto continue end end - if current == nil then - return nil - end + break + ::continue:: end + return nil end return { diff --git a/src/awesomewmdtl/visitors/module_dependencies.tl b/src/awesomewmdtl/visitors/module_dependencies.tl index e5d3e37..c6a164b 100644 --- a/src/awesomewmdtl/visitors/module_dependencies.tl +++ b/src/awesomewmdtl/visitors/module_dependencies.tl @@ -86,8 +86,23 @@ function Module_Dependencies.visit(node: Node, mod: Node, d: Dag) if type_name == mod.name then goto continue end + if utils.has_item({ + "any", + "number", + "integer", + "string", + "boolean", + "function", + "nil", + "table", + }, type_name) then + goto continue + end + if capi_class[type_name] then + goto continue + end - local dependency = dag.find_module(d, type_name) or dag.find_module(d, utils.lowercase(type_name)) or capi_class[type_name] + local dependency = dag.find_module(d, type_name) if dependency then if dependency.name ~= mod.name then mod.dependencies[dependency.name] = dependency.module_path