1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
local function findLib(var)
local value = var.value
local lib = value.lib
if not lib then
return nil
end
if lib.parent then
local res
for _, parent in ipairs(lib.parent) do
if parent.type == value.parentType then
res = parent
end
end
if not res then
res = lib.parent[1]
end
if res.type == 'object' then
local fullKey = ('*%s:%s'):format(res.nick or res.name, lib.name)
return lib, fullKey, true
else
local fullKey = ('%s.%s'):format(res.nick or res.name, lib.name)
return lib, fullKey, false
end
else
local res
if not lib.source then
return lib, lib.nick or lib.name, false
end
for _, source in ipairs(lib.source) do
if source.type == value.parentType then
res = source
end
end
if not res then
return lib, lib.nick or lib.name, false
end
return lib, res.nick or res.name or lib.nick or lib.name, false
end
end
return function (var)
local lib, fullKey, oo = findLib(var)
return lib, fullKey, oo
end
|