summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-23 15:14:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-23 15:14:32 +0800
commit4ca17e51738c2f79bb8a06be84a106b3e8311760 (patch)
treed38507cec8622f3e878d388cebf349395e08573b /script
parent13616576be75acb7b26329142591a24cd8c52669 (diff)
downloadlua-language-server-4ca17e51738c2f79bb8a06be84a106b3e8311760.zip
rawset
Diffstat (limited to 'script')
-rw-r--r--script/core/linker.lua36
-rw-r--r--script/core/searcher.lua91
2 files changed, 79 insertions, 48 deletions
diff --git a/script/core/linker.lua b/script/core/linker.lua
index 54885c48..a03c3e29 100644
--- a/script/core/linker.lua
+++ b/script/core/linker.lua
@@ -22,12 +22,15 @@ local function isGlobal(source)
if source.type == 'field' then
source = source.parent
end
- if source.type == 'getfield'
- or source.type == 'setfield' then
- local node = source.node
- if node and node.special == '_G' then
- return true
- end
+ --if source.type == 'getfield'
+ --or source.type == 'setfield' then
+ -- local node = source.node
+ -- if node and node.special == '_G' then
+ -- return true
+ -- end
+ --end
+ if source.special == '_G' then
+ return true
end
return false
end
@@ -87,6 +90,23 @@ local function getKey(source)
return source.start, nil
elseif source.type == 'select' then
return ('%d%s%s%d'):format(source.start, SPLIT_CHAR, RETURN_INDEX_CHAR, source.index)
+ elseif source.type == 'call' then
+ local node = source.node
+ if node.special == 'rawget'
+ or node.special == 'rawset' then
+ if not source.args then
+ return nil, nil
+ end
+ local tbl, key = source.args[1], source.args[2]
+ if not tbl or not key then
+ return nil, nil
+ end
+ if key.type == 'string' then
+ return ('%q'):format(key[1] or ''), tbl
+ else
+ return '', tbl
+ end
+ end
elseif source.type == 'doc.class.name'
or source.type == 'doc.type.name'
or source.type == 'doc.alias.name' then
@@ -162,10 +182,10 @@ local function getID(source)
if not node then
break
end
- if node.special == '_G' then
+ current = node
+ if current.special == '_G' then
break
end
- current = node
end
if index == 0 then
source._id = false
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index c784c3b8..517a2923 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -27,55 +27,66 @@ local m = {}
---添加结果
---@param status guide.status
---@param mode guide.searchmode
----@param ref parser.guide.object
-function m.pushResult(status, mode, ref)
- if not ref then
+---@param source parser.guide.object
+function m.pushResult(status, mode, source)
+ if not source then
return
end
local results = status.results
- local parent = ref.parent
+ local parent = source.parent
if mode == 'def' then
- if ref.type == 'local'
- or ref.type == 'setlocal'
- or ref.type == 'setglobal'
- or ref.type == 'label'
- or ref.type == 'setfield'
- or ref.type == 'setmethod'
- or ref.type == 'setindex'
- or ref.type == 'tableindex'
- or ref.type == 'tablefield'
- or ref.type == 'function'
- or ref.type == 'doc.class.name'
- or ref.type == 'doc.alias.name' then
- results[#results+1] = ref
+ if source.type == 'local'
+ or source.type == 'setlocal'
+ or source.type == 'setglobal'
+ or source.type == 'label'
+ or source.type == 'setfield'
+ or source.type == 'setmethod'
+ or source.type == 'setindex'
+ or source.type == 'tableindex'
+ or source.type == 'tablefield'
+ or source.type == 'function'
+ or source.type == 'doc.class.name'
+ or source.type == 'doc.alias.name' then
+ results[#results+1] = source
+ end
+ if source.type == 'call' then
+ if source.node.special == 'rawset' then
+ results[#results+1] = source
+ end
end
if parent.type == 'return' then
- if linker.getID(ref) ~= status.id then
- results[#results+1] = ref
+ if linker.getID(source) ~= status.id then
+ results[#results+1] = source
end
end
elseif mode == 'ref' then
- if ref.type == 'local'
- or ref.type == 'setlocal'
- or ref.type == 'getlocal'
- or ref.type == 'setglobal'
- or ref.type == 'getglobal'
- or ref.type == 'label'
- or ref.type == 'goto'
- or ref.type == 'setfield'
- or ref.type == 'getfield'
- or ref.type == 'setmethod'
- or ref.type == 'getmethod'
- or ref.type == 'setindex'
- or ref.type == 'getindex'
- or ref.type == 'tableindex'
- or ref.type == 'tablefield'
- or ref.type == 'function'
- or ref.type == 'doc.class.name'
- or ref.type == 'doc.type.name'
- or ref.type == 'doc.alias.name'
- or ref.type == 'doc.extends.name' then
- results[#results+1] = ref
+ if source.type == 'local'
+ or source.type == 'setlocal'
+ or source.type == 'getlocal'
+ or source.type == 'setglobal'
+ or source.type == 'getglobal'
+ or source.type == 'label'
+ or source.type == 'goto'
+ or source.type == 'setfield'
+ or source.type == 'getfield'
+ or source.type == 'setmethod'
+ or source.type == 'getmethod'
+ or source.type == 'setindex'
+ or source.type == 'getindex'
+ or source.type == 'tableindex'
+ or source.type == 'tablefield'
+ or source.type == 'function'
+ or source.type == 'doc.class.name'
+ or source.type == 'doc.type.name'
+ or source.type == 'doc.alias.name'
+ or source.type == 'doc.extends.name' then
+ results[#results+1] = source
+ end
+ if source.type == 'call' then
+ if source.node.special == 'rawset'
+ or source.node.special == 'rawget' then
+ results[#results+1] = source
+ end
end
elseif mode == 'field' then
end