From ed1763524f774dcb1d1b594e3d178f2b8e2460d3 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sun, 8 Jan 2023 17:45:49 +0100 Subject: [PATCH] chore(Module_Info): refactor fixup --- src/awesomewm.d.tl/entity/Module_Doc.tl | 46 +++++++++++++++++-------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/awesomewm.d.tl/entity/Module_Doc.tl b/src/awesomewm.d.tl/entity/Module_Doc.tl index 4dc1a2e..80b7582 100644 --- a/src/awesomewm.d.tl/entity/Module_Doc.tl +++ b/src/awesomewm.d.tl/entity/Module_Doc.tl @@ -29,6 +29,33 @@ local record Module_Doc populate_requires: function(Module_Doc) end +local function fixup_constructor_return_types(self: Module_Doc) + for c in self.constructors:iter() do + c:fixup() + if #c.return_types == 1 then + c.return_types[1].name = self.record_name + end + end +end + +local function fixup_methods(self: Module_Doc) + for m in self.methods:iter() do + m:fixup() + end +end + +local function fixup_properties(self: Module_Doc) + for p in self.properties:iter() do + p:fixup() + end +end + +local function fixup_static_functions(self: Module_Doc) + for s in self.static_functions:iter() do + s:fixup() + end +end + local __Module_Doc: metatable = { __call = function(_: Module_Doc): Module_Doc return { @@ -40,21 +67,10 @@ local __Module_Doc: metatable = { requires = Map(), fixup = function(self: Module_Doc) - for c in self.constructors:iter() do - c:fixup() - if #c.return_types == 1 then - c.return_types[1].name = self.record_name - end - end - for m in self.methods:iter() do - m:fixup() - end - for p in self.properties:iter() do - p:fixup() - end - for s in self.static_functions:iter() do - s:fixup() - end + fixup_constructor_return_types(self) + fixup_methods(self) + fixup_properties(self) + fixup_static_functions(self) end, populate_requires = function(self: Module_Doc) -- TODO : Move this to other Entities. Can be a little tricky because we populate a map