fix(visitor): module_dependencies DAG find_module
ci/woodpecker/pr/docker-build Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details
ci/woodpecker/pr/build-and-run Pipeline failed Details

This commit is contained in:
Aire-One 2024-01-02 17:02:54 +01:00
parent 3b3ba3476f
commit 915e089e00
2 changed files with 27 additions and 14 deletions

View File

@ -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 {

View File

@ -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