summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-31 11:26:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-31 11:26:51 +0800
commit41ed018e80df12b59cdd0e60cce7484b0c972d81 (patch)
tree53926994aac1bdd07597fd2683606714072954e9 /script
parent51a43979dc277e1a4418725cd001b5520d84588d (diff)
downloadlua-language-server-41ed018e80df12b59cdd0e60cce7484b0c972d81.zip
fix reference cross generic return
Diffstat (limited to 'script')
-rw-r--r--script/core/definition.lua3
-rw-r--r--script/core/guide.lua42
-rw-r--r--script/core/highlight.lua3
-rw-r--r--script/core/reference.lua3
4 files changed, 27 insertions, 24 deletions
diff --git a/script/core/definition.lua b/script/core/definition.lua
index 8fa9bce0..b26bb922 100644
--- a/script/core/definition.lua
+++ b/script/core/definition.lua
@@ -137,6 +137,9 @@ return function (uri, offset)
end
for _, src in ipairs(defs) do
+ if src.dummy then
+ goto CONTINUE
+ end
if values[src] then
goto CONTINUE
end
diff --git a/script/core/guide.lua b/script/core/guide.lua
index 67fd9ad2..4ce1edf9 100644
--- a/script/core/guide.lua
+++ b/script/core/guide.lua
@@ -3003,11 +3003,7 @@ function m.searchSameFields(status, simple, mode)
local queues, starts, forces = allocQueue()
local queueLen = 0
local locks = {}
- local function pushQueue(obj, start, force)
- if obj.type == 'getlocal'
- or obj.type == 'setlocal' then
- obj = obj.node
- end
+ local function appendQueue(obj, start, force)
local lock = locks[start]
if not lock then
lock = {}
@@ -3021,37 +3017,35 @@ function m.searchSameFields(status, simple, mode)
queues[queueLen] = obj
starts[queueLen] = start
forces[queueLen] = force
- if obj.type == 'local' and obj.ref then
- for _, ref in ipairs(obj.ref) do
+ if obj.mirror then
+ if not lock[obj.mirror] then
+ lock[obj.mirror] = true
queueLen = queueLen + 1
- queues[queueLen] = ref
+ queues[queueLen] = obj.mirror
starts[queueLen] = start
forces[queueLen] = force
end
end
+ end
+ local function pushQueue(obj, start, force)
+ if obj.type == 'getlocal'
+ or obj.type == 'setlocal' then
+ obj = obj.node
+ end
+ appendQueue(obj, start, force)
+ if obj.type == 'local' and obj.ref then
+ for _, ref in ipairs(obj.ref) do
+ appendQueue(ref, start, force)
+ end
+ end
if m.isGlobal(obj) then
local refs = m.checkSameSimpleInGlobal(status, obj)
if refs then
for _, ref in ipairs(refs) do
- if not lock[ref] then
- lock[ref] = true
- queueLen = queueLen + 1
- queues[queueLen] = ref
- starts[queueLen] = start
- forces[queueLen] = force
- end
+ appendQueue(ref, start, force)
end
end
end
- if obj.mirror then
- if not lock[obj.mirror] then
- lock[obj.mirror] = true
- queueLen = queueLen + 1
- queues[queueLen] = obj.mirror
- starts[queueLen] = start
- forces[queueLen] = force
- end
- end
end
if simple.mode == 'global' then
-- 全局变量开头
diff --git a/script/core/highlight.lua b/script/core/highlight.lua
index 01f9178a..e79bb797 100644
--- a/script/core/highlight.lua
+++ b/script/core/highlight.lua
@@ -167,6 +167,9 @@ return function (uri, offset)
local source = findSource(ast, offset, accept)
if source then
find(source, uri, function (target)
+ if target.dummy then
+ return
+ end
local kind
if target.type == 'getfield' then
target = target.field
diff --git a/script/core/reference.lua b/script/core/reference.lua
index e0febc9c..7620b09e 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -66,6 +66,9 @@ return function (uri, offset)
local results = {}
for _, src in ipairs(vm.getRefs(source, 5)) do
+ if src.dummy then
+ goto CONTINUE
+ end
local root = guide.getRoot(src)
if not root then
goto CONTINUE