summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-05-27 14:44:34 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-05-27 14:44:34 +0800
commited764615146751a0a9a0d9169a84b9fb9f5248e9 (patch)
tree28424abce891830fee63c49ac9b679b0e069415d
parent2474d6a76bd84c2816c4f458d36089c0ea96158c (diff)
downloadlua-language-server-ed764615146751a0a9a0d9169a84b9fb9f5248e9.zip
cleanup
-rw-r--r--script/parser/luadoc.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 85215140..6f35052b 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -1114,17 +1114,25 @@ local function bindDocsBetween(sources, binded, bindSources, start, finish)
end
local src = sources[index]
if src.start < start then
- left = index
+ left = index + 1
else
right = index
end
end
- for i = index - 1, max do
+
+ -- 从前往后进行绑定
+ for i = index, max do
local src = sources[i]
if src then
if src.start > finish then
break
end
+ -- 遇到table后中断,处理以下情况:
+ -- ---@type AAA
+ -- local t = {x = 1, y = 2}
+ if src.type == 'table' then
+ break
+ end
if src.start >= start then
src.bindDocs = binded
bindSources[#bindSources+1] = src
@@ -1220,13 +1228,10 @@ local function bindDocs(state)
or src.type == 'tablefield'
or src.type == 'tableindex'
or src.type == 'function'
+ or src.type == 'table'
or src.type == '...' then
sources[#sources+1] = src
end
- if src.type == 'table' then
- -- TODO
- return true
- end
end)
table.sort(sources, function (a, b)
return a.start < b.start