summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-12-02 20:11:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-12-02 20:11:30 +0800
commit830be2cab0d5e45a32606bb33eba216c72a9ca66 (patch)
tree9e400ab0c69e238d5966d9f23918e4353c5ff09e /script/vm
parent5833c2aef04bd4704c86104275411ef330981f85 (diff)
downloadlua-language-server-830be2cab0d5e45a32606bb33eba216c72a9ca66.zip
fully support Doc.type.array
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/getDocs.lua16
-rw-r--r--script/vm/guideInterface.lua16
2 files changed, 32 insertions, 0 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 0f4b537d..62e12d18 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -84,6 +84,22 @@ function vm.getDocTypes(name)
return cache
end
+function vm.getDocClass(name)
+ local cache = vm.getCache('getDocClass')[name]
+ if cache ~= nil then
+ return cache
+ end
+ cache = {}
+ local results = getDocTypes(name)
+ for _, doc in ipairs(results) do
+ if doc.type == 'doc.class.name' then
+ cache[#cache+1] = doc
+ end
+ end
+ vm.getCache('getDocClass')[name] = cache
+ return cache
+end
+
function vm.isMetaFile(uri)
local status = files.getAst(uri)
if not status then
diff --git a/script/vm/guideInterface.lua b/script/vm/guideInterface.lua
index e646def8..eb809c30 100644
--- a/script/vm/guideInterface.lua
+++ b/script/vm/guideInterface.lua
@@ -82,7 +82,23 @@ function vm.interface.global(name)
return vm.getGlobals(name)
end
+local basicTypes = {
+ ['any'] = true,
+ ['nil'] = true,
+ ['boolean'] = true,
+ ['number'] = true,
+ ['integer'] = true,
+ ['thread'] = true,
+ ['table'] = true,
+ ['string'] = true,
+ ['userdata'] = true,
+ ['lightuserdata'] = true,
+ ['function'] = true,
+}
function vm.interface.docType(name)
+ if basicTypes[name] then
+ return vm.getDocClass(name)
+ end
await.delay()
return vm.getDocTypes(name)
end