summaryrefslogtreecommitdiff
path: root/script/parser/luadoc.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-29 14:23:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-29 14:23:47 +0800
commitde7ecfaa8305cf7e02f8ffd3368f55837d30d5c9 (patch)
treeb5f852a42c6f027a5ce420c773577c41c2832a21 /script/parser/luadoc.lua
parent2080c5627ee1a899731be849a10931695fa627d0 (diff)
downloadlua-language-server-de7ecfaa8305cf7e02f8ffd3368f55837d30d5c9.zip
cleanup
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r--script/parser/luadoc.lua24
1 files changed, 16 insertions, 8 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 0aa98482..e5e10331 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -1172,8 +1172,18 @@ local function buildLuaDoc(comment)
end
---当前行在注释doc前是否有代码
-local function haveCodeBeforeDocInCurLine(text, lineData, docStartCol)
- return text:sub(lineData.start + 1, docStartCol - 1):find '[^ \t]'
+local function haveCodeBeforeDocInCurLine(text, lineData, docStart)
+ return text:sub(lineData.start + 1, docStart - 1):find '[%w_]'
+end
+
+local function isTailComment(lns, text, binded, doc)
+ local lastDoc = binded[#binded]
+ local lastDocStartRow = guide.positionOf(lns, lastDoc.originalComment.start)
+ local lastDocStartLineData = guide.lineData(lns, lastDocStartRow)
+ if haveCodeBeforeDocInCurLine(text, lastDocStartLineData, lastDoc.originalComment.start) then
+ return true
+ end
+ return false
end
local function isNextLine(lns, text, binded, doc)
@@ -1181,12 +1191,6 @@ local function isNextLine(lns, text, binded, doc)
return false
end
local lastDoc = binded[#binded]
- local lastDocStartRow, lastDocStartCol = guide.positionOf(lns, lastDoc.originalComment.start)
- local lastDocStartLineData = guide.lineData(lns, lastDocStartRow)
- if haveCodeBeforeDocInCurLine(text, lastDocStartLineData, lastDocStartCol) then
- return false
- end
-
local lastRow = guide.positionOf(lns, lastDoc.finish)
local newRow = guide.positionOf(lns, doc.start)
return newRow - lastRow == 1
@@ -1368,6 +1372,10 @@ local function bindDocs(state)
state.ast.docs.groups[#state.ast.docs.groups+1] = binded
end
binded[#binded+1] = doc
+ if isTailComment(Lines, text, binded, doc) then
+ bindDoc(sources, Lines, binded)
+ binded = nil
+ end
end
bindDoc(sources, Lines, binded)
end