summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-27 19:24:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-27 19:24:18 +0800
commit426ee9071b8aabcd9065ba7055d8ac416c95641d (patch)
treefc4b77460636cc559dd1e42fe6475f17be89dcc0 /script
parentc88ea6274f90bad38db2383e67121c2ae48c7970 (diff)
downloadlua-language-server-426ee9071b8aabcd9065ba7055d8ac416c95641d.zip
stash
Diffstat (limited to 'script')
-rw-r--r--script/core/linker.lua32
-rw-r--r--script/core/searcher.lua13
2 files changed, 34 insertions, 11 deletions
diff --git a/script/core/linker.lua b/script/core/linker.lua
index 97ff4927..f0e30e63 100644
--- a/script/core/linker.lua
+++ b/script/core/linker.lua
@@ -4,7 +4,7 @@ local guide = require 'parser.guide'
local Linkers
local LastIDCache = {}
local SPLIT_CHAR = '\x1F'
-local SPLIT_REGEX = SPLIT_CHAR .. '[^' .. SPLIT_CHAR .. ']+$'
+local SPLIT_REGEX = SPLIT_CHAR .. '[^' .. SPLIT_CHAR .. ']*$'
local RETURN_INDEX_CHAR = '#'
local PARAM_INDEX_CHAR = '@'
@@ -130,6 +130,7 @@ local function getKey(source)
or source.type == 'doc.param'
or source.type == 'doc.vararg'
or source.type == 'doc.field.name'
+ or source.type == 'doc.type.table'
or source.type == 'doc.type.function' then
return source.start, nil
elseif source.type == 'doc.see.field' then
@@ -176,7 +177,10 @@ local function checkMode(source)
return 'da:'
end
if source.type == 'doc.type.function' then
- return 'df:'
+ return 'dfun:'
+ end
+ if source.type == 'doc.type.table' then
+ return 'dtbl:'
end
if source.type == 'doc.vararg' then
return 'dv:'
@@ -440,6 +444,28 @@ local function compileLink(source)
--pushBackward(indexID, callID)
end
end
+ if source.type == 'doc.type.function' then
+ if source.returns then
+ for index, rtn in ipairs(source.returns) do
+ local returnID = ('%s%s%s%s'):format(
+ id,
+ SPLIT_CHAR,
+ RETURN_INDEX_CHAR,
+ index
+ )
+ pushForward(returnID, getID(rtn))
+ end
+ end
+ end
+ if source.type == 'doc.type.table' then
+ if source.value then
+ local valueID = ('%s%s'):format(
+ id,
+ SPLIT_CHAR
+ )
+ pushForward(valueID, getID(source.value))
+ end
+ end
-- 将函数的返回值映射到具体的返回值上
if source.type == 'function' then
-- 检查实体返回值
@@ -455,7 +481,7 @@ local function compileLink(source)
end
for index, rtnObjs in ipairs(returns) do
local returnID = ('%s%s%s%s'):format(
- getID(source),
+ id,
SPLIT_CHAR,
RETURN_INDEX_CHAR,
index
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index abfcf059..30d2e33a 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -176,20 +176,17 @@ function m.searchRefsByID(status, uri, expect, mode)
local index = 0
local function search(id, field, callinfo)
- local fullID
+ local fieldLen
if field then
- fullID = id .. MARK_CHAR .. field
local _, len = field:gsub(linker.SPLIT_CHAR, '')
- if len >= 10 then
- return
- end
+ fieldLen = len
else
- fullID = id
+ fieldLen = 0
end
- if mark[fullID] then
+ if mark[id] and mark[id] <= fieldLen then
return
end
- mark[fullID] = true
+ mark[id] = fieldLen
index = index + 1
queueIDs[index] = id
queueFields[index] = field