summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorLei Zhu <uhziel@gmail.com>2021-01-05 20:50:51 +0800
committerLei Zhu <uhziel@gmail.com>2021-01-05 20:50:51 +0800
commit217aa4e586b1786bc6b82828279b745a29290f4d (patch)
tree9b8350127704653ac5c80b2b81497a5d27729918 /script
parenteb87cc84f2475911c2086da982902c75f3bfdd3a (diff)
downloadlua-language-server-217aa4e586b1786bc6b82828279b745a29290f4d.zip
通过扩展 getArrayLevel 来找到层级
Diffstat (limited to 'script')
-rw-r--r--script/parser/guide.lua20
-rw-r--r--script/vm/getDocs.lua5
2 files changed, 18 insertions, 7 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 5264a2b6..d0e82ba8 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1663,12 +1663,20 @@ function m.checkSameSimpleOfRefByDocSource(status, obj, start, pushQueue, mode)
end
end
-local function getArrayLevel(obj)
+local function getArrayOrTableLevel(obj)
local level = 0
while true do
local parent = obj.parent
if parent.type == 'doc.type.array' then
level = level + 1
+ elseif parent.type == 'doc.type.table' then
+ if obj.type == 'doc.type' then
+ level = level + 1
+ -- else 只存在 obj.type == 'doc.type.name' 的情况,即 table<k,v> 中的 table,这种是不需要再增加层级的
+ end
+ elseif parent.type == 'doc.type' and parent.parent and parent.parent.type == 'doc.type.table' then
+ level = level + 1
+ parent = parent.parent
else
break
end
@@ -1725,12 +1733,10 @@ function m.checkSameSimpleByDoc(status, obj, start, pushQueue, mode)
for _, res in ipairs(pieceResult) do
pushQueue(res, start, true)
end
- local parentDocTypeTable = m.getParentDocTypeTable(obj)
- if not parentDocTypeTable then
- local state = m.getDocState(obj)
- if state.type == 'doc.type' and mode == 'ref' then
- m.checkSameSimpleOfRefByDocSource(status, state, start - getArrayLevel(obj), pushQueue, mode)
- end
+
+ local state = m.getDocState(obj)
+ if state.type == 'doc.type' and mode == 'ref' then
+ m.checkSameSimpleOfRefByDocSource(status, state, start - getArrayOrTableLevel(obj), pushQueue, mode)
end
return true
elseif obj.type == 'doc.field' then
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 632dd1c2..790a9b50 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -16,6 +16,11 @@ local function getTypesOfFile(uri)
or src.type == 'doc.class.name'
or src.type == 'doc.extends.name'
or src.type == 'doc.alias.name' then
+ if src.type == 'doc.type.name' then
+ if guide.getParentDocTypeTable(src) then
+ return
+ end
+ end
local name = src[1]
if name then
if not types[name] then