diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-07 17:48:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-07 17:48:31 +0800 |
commit | 8123dd362c1991ac87a26822729f24a53ef6b35e (patch) | |
tree | 610a0177ad0b1387e9ecc680c586c957930b76dd /script/parser | |
parent | 56e30b07fffee79e6c0612f0f099eb590c7be558 (diff) | |
download | lua-language-server-8123dd362c1991ac87a26822729f24a53ef6b35e.zip |
resolve #455 tail comments support lua string
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/luadoc.lua | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 74e53718..3ab9f6a1 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -2,6 +2,7 @@ local m = require 'lpeglabel' local re = require 'parser.relabel' local lines = require 'parser.lines' local guide = require 'core.guide' +local grammar = require 'parser.grammar' local TokenTypes, TokenStarts, TokenFinishs, TokenContents local Ci, Offset, pushError, Ct, NextComment, Lines @@ -999,16 +1000,23 @@ local function convertTokens() end local function trimTailComment(text) + local comment = text if text:sub(1, 1) == '@' then - return text:sub(2) + comment = text:sub(2) end if text:sub(1, 1) == '#' then - return text:sub(2) + comment = text:sub(2) end if text:sub(1, 2) == '--' then - return text:sub(3) + comment = text:sub(3) end - return text + if comment:find '^%s*[\'"[]' then + local result = grammar(nil, comment:gsub('^%s+', ''), 'string') + if result then + comment = result[1][1] + end + end + return comment end local function buildLuaDoc(comment) @@ -1185,7 +1193,7 @@ local function bindDoc(sources, lns, binded) end bindGeneric(binded) local row = guide.positionOf(lns, lastDoc.finish) - local cstart, cfinish = guide.lineRange(lns, row) + local cstart, cfinish = guide.lineRange(lns, row) local nstart, nfinish = guide.lineRange(lns, row + 1) bindDocsBetween(sources, binded, bindSources, cstart, cfinish) if #bindSources == 0 then |