summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-17 23:46:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-17 23:46:38 +0800
commite9fcf13480ed98af15201911cad542fe6e84dc1e (patch)
tree577422178b2d4ca28d1186faff7a010fdea6b9f9
parente8ea5f90e60e36833b3e2d98e66d89e6098faacc (diff)
downloadlua-language-server-e9fcf13480ed98af15201911cad542fe6e84dc1e.zip
修正一些bug
-rw-r--r--server-beta/src/core/highlight.lua37
-rw-r--r--server-beta/src/parser/guide.lua2
-rw-r--r--server-beta/src/searcher/eachRef.lua3
-rw-r--r--server-beta/test/highlight/init.lua4
4 files changed, 32 insertions, 14 deletions
diff --git a/server-beta/src/core/highlight.lua b/server-beta/src/core/highlight.lua
index 8c609485..9aaf62b8 100644
--- a/server-beta/src/core/highlight.lua
+++ b/server-beta/src/core/highlight.lua
@@ -14,20 +14,35 @@ end
local function ofField(source, uri, callback)
local parent = source.parent
- if not parent or not parent.node then
+ if not parent then
return
end
local myKey = guide.getKeyName(source)
- searcher.eachField(parent.node, function (info)
- if info.key ~= myKey then
- return
- end
- local destUri = guide.getRoot(info.source).uri
- if destUri ~= uri then
- return
- end
- callback(info.source)
- end)
+ if parent.type == 'tableindex'
+ or parent.type == 'tablefield' then
+ local tbl = parent.parent
+ searcher.eachField(tbl, function (info)
+ if info.key ~= myKey then
+ return
+ end
+ local destUri = guide.getRoot(info.source).uri
+ if destUri ~= uri then
+ return
+ end
+ callback(info.source)
+ end)
+ else
+ searcher.eachField(parent.node, function (info)
+ if info.key ~= myKey then
+ return
+ end
+ local destUri = guide.getRoot(info.source).uri
+ if destUri ~= uri then
+ return
+ end
+ callback(info.source)
+ end)
+ end
end
local function ofIndex(source, uri, callback)
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index 3c8bc3fc..80f9d160 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -46,7 +46,7 @@ m.childMap = {
['select'] = {'vararg'},
['table'] = {'#'},
['tableindex'] = {'index', 'value'},
- ['tablefield'] = {'value'},
+ ['tablefield'] = {'field', 'value'},
['function'] = {'args', '#'},
['funcargs'] = {'#'},
['setmethod'] = {'node', 'method', 'value'},
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua
index 24f2ea77..9a3fd9f0 100644
--- a/server-beta/src/searcher/eachRef.lua
+++ b/server-beta/src/searcher/eachRef.lua
@@ -427,8 +427,7 @@ local function eachRef(source, callback)
or stype == 'method' then
ofField(source, callback)
elseif stype == 'setfield'
- or stype == 'getfield'
- or stype == 'tablefield' then
+ or stype == 'getfield' then
ofField(source.field, callback)
elseif stype == 'setmethod'
or stype == 'getmethod' then
diff --git a/server-beta/test/highlight/init.lua b/server-beta/test/highlight/init.lua
index fbde194b..0b916fd1 100644
--- a/server-beta/test/highlight/init.lua
+++ b/server-beta/test/highlight/init.lua
@@ -68,6 +68,10 @@ a = t.<!a!>
]]
TEST [[
+t = {
+ [<!"a"!>] = 1,
+ <!a!> = 1,
+}
t[<!'a'!>] = 1
a = t.<!a!>
]]