summaryrefslogtreecommitdiff
path: root/script-beta/vm/getLibrary.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-05-30 16:17:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-05-30 16:17:21 +0800
commitdb3fe02b476bc81bf7b0dc00125a4622346c0b92 (patch)
treee4aa6913f1dc2f9363309078f6e259516f0c7204 /script-beta/vm/getLibrary.lua
parent245c99bb1ca69dab538c3106b640a478f963d6ed (diff)
downloadlua-language-server-db3fe02b476bc81bf7b0dc00125a4622346c0b92.zip
hover 合并 value
Diffstat (limited to 'script-beta/vm/getLibrary.lua')
-rw-r--r--script-beta/vm/getLibrary.lua38
1 files changed, 22 insertions, 16 deletions
diff --git a/script-beta/vm/getLibrary.lua b/script-beta/vm/getLibrary.lua
index 2af94440..395a5b74 100644
--- a/script-beta/vm/getLibrary.lua
+++ b/script-beta/vm/getLibrary.lua
@@ -6,16 +6,27 @@ local function checkStdLibrary(source)
if source.library then
return source
end
- if source.type ~= 'getglobal'
- and source.type ~= 'setglobal' then
- return
- end
- local name = guide.getName(source)
- if not name then
- return nil
- end
- if library.global[name] then
+ if source.type == 'getglobal'
+ or source.type == 'setglobal' then
+ local name = guide.getName(source)
return library.global[name]
+ elseif source.type == 'select' then
+ local call = source.vararg
+ if call.type ~= 'call' then
+ goto CONTINUE
+ end
+ local func = call.node
+ local lib = vm.getLibrary(func)
+ if not lib then
+ goto CONTINUE
+ end
+ if lib.name == 'require' then
+ local modName = call.args[1]
+ if modName and modName.type == 'string' then
+ return library.library[modName[1]]
+ end
+ end
+ ::CONTINUE::
end
end
@@ -32,13 +43,8 @@ local function getLibInNode(source, nodeLib)
end
local function getNodeAsTable(source)
- local node = source.node
- if node.type ~= 'getglobal'
- and node.type ~= 'setglobal' then
- return
- end
- local name = guide.getName(node)
- return getLibInNode(source, library.global[name])
+ local nodeLib = checkStdLibrary(source.node)
+ return getLibInNode(source, nodeLib)
end
local function getNodeAsObject(source)