summaryrefslogtreecommitdiff
path: root/server/src/matcher/vm.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-12 16:10:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-12 16:10:26 +0800
commitfa0f8b12d5e6d15bd3a3fdb994c20d2fce2a1fbf (patch)
treed5e6ef03e3b753af8a4fcbf95f58c3ae2fcd79ff /server/src/matcher/vm.lua
parentee64096a59701bb9a756b44da3e51ec198920601 (diff)
downloadlua-language-server-fa0f8b12d5e6d15bd3a3fdb994c20d2fce2a1fbf.zip
find_lib支持对象
Diffstat (limited to 'server/src/matcher/vm.lua')
-rw-r--r--server/src/matcher/vm.lua34
1 files changed, 27 insertions, 7 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 16d5fe20..928a954f 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -386,9 +386,34 @@ function mt:createValue(type, source, v)
source = source or DefaultSource,
value = v,
}
+ local lib = library.object[type]
+ if lib then
+ self:getLibChild(value, lib, 'object')
+ end
return value
end
+function mt:getLibChild(value, lib, parentType)
+ if lib.child then
+ if self.libraryChild[lib] then
+ value.child = self.libraryChild[lib]
+ return
+ end
+ self.libraryChild[lib] = {}
+ for fName, fLib in pairs(lib.child) do
+ local fField = self:createField(value, fName)
+ local fValue = self:getLibValue(fLib, parentType)
+ self:setValue(fField, fValue)
+ end
+ if value.child then
+ for k, v in pairs(value.child) do
+ self.libraryChild[lib][k] = v
+ end
+ end
+ value.child = self.libraryChild[lib]
+ end
+end
+
function mt:getLibValue(lib, parentType, v)
if self.libraryValue[lib] then
return self.libraryValue[lib]
@@ -433,13 +458,7 @@ function mt:getLibValue(lib, parentType, v)
value.lib = lib
value.parentType = parentType
- if lib.child then
- for fName, fLib in pairs(lib.child) do
- local fField = self:createField(value, fName)
- local fValue = self:getLibValue(fLib, parentType)
- self:setValue(fField, fValue)
- end
- end
+ self:getLibChild(value, lib, parentType)
return value
end
@@ -875,6 +894,7 @@ local function compile(ast)
calls = {},
},
libraryValue = {},
+ libraryChild = {},
}, mt)
-- 创建初始环境