summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-10 10:55:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-10 10:55:32 +0800
commit871035d0574b96175f44cdedd0f8256ae74a0534 (patch)
tree7b2c7c7d9ea6ed1115f064f5c2cf482d928d1a9c /script/core
parentd7ab66b25db024f2cb375192f36d3c72313e0e34 (diff)
downloadlua-language-server-871035d0574b96175f44cdedd0f8256ae74a0534.zip
improve
Diffstat (limited to 'script/core')
-rw-r--r--script/core/noder.lua36
1 files changed, 30 insertions, 6 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 1cb49e5e..ac1d96d8 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -124,7 +124,15 @@ local getKeyMap = util.switch()
end)
: case 'tablefield'
: call(function (source)
- return STRING_CHAR .. (source.field and source.field[1] or ''), source.parent
+ local t = source.parent
+ local parent = t.parent
+ local node
+ if parent.value == t then
+ node = parent
+ else
+ node = t
+ end
+ return STRING_CHAR .. (source.field and source.field[1] or ''), node
end)
: case 'getmethod'
: case 'setmethod'
@@ -150,24 +158,40 @@ local getKeyMap = util.switch()
end)
: case 'tableindex'
: call(function (source)
+ local t = source.parent
+ local parent = t.parent
+ local node
+ if parent.value == t then
+ node = parent
+ else
+ node = t
+ end
local index = source.index
if not index then
- return ANY_FIELD_CHAR, source.parent
+ return ANY_FIELD_CHAR, node
end
if index.type == 'string' then
- return STRING_CHAR .. (index[1] or ''), source.parent
+ return STRING_CHAR .. (index[1] or ''), node
elseif index.type == 'boolean'
or index.type == 'integer'
or index.type == 'number' then
- return tostring(index[1] or ''), source.parent
+ return tostring(index[1] or ''), node
elseif index.type ~= 'function'
and index.type ~= 'table' then
- return ANY_FIELD_CHAR, source.parent
+ return ANY_FIELD_CHAR, node
end
end)
: case 'tableexp'
: call(function (source)
- return tostring(source.tindex), source.parent
+ local t = source.parent
+ local parent = t.parent
+ local node
+ if parent.value == t then
+ node = parent
+ else
+ node = t
+ end
+ return tostring(source.tindex), node
end)
: case 'table'
: call(function (source)