Page MenuHomePhabricator
Paste P258

script
ActivePublic

Authored by zmike on Jan 8 2019, 11:24 AM.
--
-- Execute with:
-- elua print_hierarchy.lua class_file_name.eo
--
local eolian = require("eolian")
local file = arg[1]
local eos = eolian.new()
eos:directory_add("src/lib")
eos:all_eot_files_parse()
eos:file_parse(file)
local function print_hierarchy(cl, level)
level = level or 1
local t = cl:type_get()
-- local legacy = cl:legacy_prefix_get()
if t==0 then print("unknown " .. cl:name_get())
elseif t==1 then
io.write("class " .. cl:name_get())
-- if legacy then print(" (" .. legacy .. ")")
-- else print("")
-- end
elseif t==2 then print("abstract " .. cl:name_get())
elseif t==3 then print("mixin " .. cl:name_get())
elseif t==4 then print("interface " .. cl:name_get())
end
--print(cl:documentation_get():summary_get())
for m in cl:functions_get(eolian.function_type.PROPERTY) do
for i = 1, level - 1 do io.write(" |") end
io.write("├ (P) " .. m:name_get())
if m:scope_get(eolian.function_type.PROP_SET) == eolian.object_scope.PROTECTED then io.write(" :: set@protected")
end
if m:is_beta() then io.write(" @beta")
end
print("")
end
for m in cl:functions_get(eolian.function_type.METHOD) do
for i = 1, level - 1 do io.write(" |") end
io.write("├ (M) " .. m:name_get())
if m:scope_get(eolian.function_type.METHOD) == eolian.object_scope.PROTECTED then io.write(" :: @protected")
end
if m:is_beta() then io.write(" @beta")
end
print("")
end
for e in cl:events_get() do
for i = 1, level - 1 do io.write(" |") end
print("├ (E) " .. e:name_get())
end
print("")
if cl:parent_get() then
for i = 1, level do io.write(" |") end
print_hierarchy(cl:parent_get(), level + 1)
end
for icl in cl:extensions_get() do
for i = 1, level do io.write(" |") end
print_hierarchy(icl, level + 1)
end
end
print_hierarchy(eos:class_by_file_get(file))
return true
zmike created this paste.Jan 8 2019, 11:24 AM
zmike created this object with visibility "Public (No Login Required)".
zmike edited the content of this paste. (Show Details)Sep 24 2019, 11:59 AM