WIP: awesomerc.tl should work #85

Draft
Aire-One wants to merge 40 commits from feat/#58 into master
2 changed files with 35 additions and 0 deletions
Showing only changes of commit 35c904c16d - Show all commits

View File

@ -15,6 +15,7 @@ local module_descendants <const> = require("awesomewmdtl.visitors.module_descend
local type Node = require("awesomewmdtl.types.Node")
local node_fixer <const> = require("awesomewmdtl.visitors.node_fixer")
local property <const> = require("awesomewmdtl.property")
local remove_duplicate_fields <const> = require("awesomewmdtl.visitors.remove_duplicate_fields")
local scraper <const> = require("awesomewmdtl.scraper")
local type_mapping <const> = require("awesomewmdtl.visitors.type_mapping")
local utils <const> = require("awesomewmdtl.utils")
@ -111,6 +112,9 @@ for _,root in dag.iter_global_nodes(module_dag) do
end
for root in dag.iter_modules(module_dag) do
ast.in_order_visitor(root, function(node: Node)
remove_duplicate_fields.visit(node)
end)
ast.in_order_visitor(root, function(node: Node)
node_fixer.visit(node, root)
end)

View File

@ -0,0 +1,31 @@
local type Node = require("awesomewmdtl.types.Node")
local utils <const> = require("awesomewmdtl.utils")
local has_item <const> = utils.has_item
-- This is quick hack to remove duplicate fields from a module
-- We can have duplicated fields in a module, because we currently
-- don't make difference between module record and instance record.
-- So static module fields and instance level fields are mixed together.
local record Remove_Duplicate_Fields
visit: function(node: Node)
end
function Remove_Duplicate_Fields.visit(node: Node)
if node.token ~= "module" then
return
end
local fields: { string } = {}
for i, n in ipairs(node.children) do
if has_item(fields, n.name) then
table.remove(node.children, i)
else
table.insert(fields, n.name)
end
end
end
return Remove_Duplicate_Fields