summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-07 18:40:34 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-07 18:40:34 +0800
commit11acb1981bf74b012cd02e4c140577f29692fc98 (patch)
treeaf2ff463280d7a09a8ed94d2ba23c80f9cffe866 /server/src
parentf37431779e9975d0c71c196ac563ccecdb3f79ea (diff)
downloadlua-language-server-11acb1981bf74b012cd02e4c140577f29692fc98.zip
支持昵称
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/find_lib.lua30
1 files changed, 15 insertions, 15 deletions
diff --git a/server/src/matcher/find_lib.lua b/server/src/matcher/find_lib.lua
index 5da379c6..3d98aef7 100644
--- a/server/src/matcher/find_lib.lua
+++ b/server/src/matcher/find_lib.lua
@@ -118,35 +118,35 @@ local function isGlobal(var)
return var.parent.key == '_ENV' or var.parent.key == '_G'
end
-local function checkSourceAsGlobal(value, name)
+local function checkSourceAsGlobal(value, name, showname)
if value.key == name and isGlobal(value) then
- return name
+ return showname or name
end
return nil
end
-local function checkSourceAsLibrary(value, name)
+local function checkSourceAsLibrary(value, name, showname)
if value.type ~= 'lib' then
return nil
end
if value.name == name then
- return name
+ return showname or name
end
return nil
end
-local function checkSource(value, name, lib)
+local function checkSource(value, libname, lib)
if not lib.source then
- return checkSourceAsGlobal(value, name)
+ return checkSourceAsGlobal(value, libname)
end
for _, source in ipairs(lib.source) do
if source.type == 'global' then
- local fullKey = checkSourceAsGlobal(value, name)
+ local fullKey = checkSourceAsGlobal(value, source.name or libname, source.nick or libname)
if fullKey then
return fullKey
end
elseif source.type == 'library' then
- local fullKey = checkSourceAsLibrary(value, name)
+ local fullKey = checkSourceAsLibrary(value, source.name or libname, source.nick or libname)
if fullKey then
return fullKey
end
@@ -156,19 +156,19 @@ local function checkSource(value, name, lib)
end
local function checkParentAsGlobal(parentValue, name, parent)
- local parentName = checkSourceAsGlobal(parentValue, parent.name)
+ local parentName = checkSourceAsGlobal(parentValue, parent.name, parent.nick)
if not parentName then
return nil
end
- return ('%s.%s'):format(parent.name, name)
+ return ('%s.%s'):format(parentName, name)
end
local function checkParentAsLibrary(parentValue, name, parent)
- local parentName = checkSourceAsLibrary(parentValue, parent.name)
+ local parentName = checkSourceAsLibrary(parentValue, parent.name, parent.nick)
if not parentName then
return nil
end
- return ('%s.%s'):format(parent.name, name)
+ return ('%s.%s'):format(parentName, name)
end
local function checkParentAsObject(parentValue, name, parent)
@@ -213,12 +213,12 @@ end
local function findLib(var, libs)
local value = var.value or var
- for name, lib in pairs(libs) do
- local fullKey = checkSource(value, name, lib)
+ for libname, lib in pairs(libs) do
+ local fullKey = checkSource(value, libname, lib)
if fullKey then
return lib, fullKey, false
end
- local fullKey, oo = checkParent(value, name, lib)
+ local fullKey, oo = checkParent(value, libname, lib)
if fullKey then
return lib, fullKey, oo
end