summaryrefslogtreecommitdiff
path: root/script/parser/luadoc.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-29 16:02:15 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-29 16:02:15 +0800
commit46910e464bfab9992895898b4c1795e494796e39 (patch)
tree4a8580f9fa9d983b3a6f932a24011668d4938a67 /script/parser/luadoc.lua
parent72fccb749b959881011e0ab0830c11917bfc3c55 (diff)
downloadlua-language-server-46910e464bfab9992895898b4c1795e494796e39.zip
resolve #1248 supports spaces before `--[[@as]]`
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r--script/parser/luadoc.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 1e7a6ab3..c2019d8d 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -142,6 +142,7 @@ Symbol <- ({} {
---@field signs parser.object[]
---@field originalComment parser.object
---@field as? parser.object
+---@field touch? integer
local function trim(str)
return str:match '^%s*(%S+)%s*$'
@@ -1671,6 +1672,22 @@ local function bindDocs(state)
end
end
+local function findTouch(state, doc)
+ local text = state.lua
+ local pos = guide.positionToOffset(state, doc.originalComment.start)
+ for i = pos - 2, 1, -1 do
+ local c = text:sub(i, i)
+ if c == '\r'
+ or c == '\n' then
+ break
+ elseif c ~= ' '
+ and c ~= '\t' then
+ doc.touch = guide.offsetToPosition(state, i)
+ break
+ end
+ end
+end
+
return function (state)
local ast = state.ast
local comments = state.comms
@@ -1714,6 +1731,9 @@ return function (state)
ast.finish = doc.finish
end
doc.originalComment = comment
+ if comment.type == 'comment.long' then
+ findTouch(state, doc)
+ end
end
end