diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-26 12:04:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-26 12:04:14 +0800 |
commit | 84f4da78a9b07823f6d78409fea8d373b6fbc3b6 (patch) | |
tree | 9e346c593b32fd7315b9bc7b94ff4839ff7f2ad5 /script/parser | |
parent | cac8e5971b885a8a4dd865713bf0cd2972b1f011 (diff) | |
download | lua-language-server-84f4da78a9b07823f6d78409fea8d373b6fbc3b6.zip |
luadoc support tailcomment
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/guide.lua | 24 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 20 |
2 files changed, 23 insertions, 21 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 7ca3ddd0..bc82ec57 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -84,18 +84,18 @@ m.childMap = { ['unary'] = {1}, ['doc'] = {'#'}, - ['doc.class'] = {'class', 'extends'}, - ['doc.type'] = {'#types', '#enums', 'name'}, - ['doc.alias'] = {'alias', 'extends'}, - ['doc.param'] = {'param', 'extends'}, - ['doc.return'] = {'#returns'}, - ['doc.field'] = {'field', 'extends'}, - ['doc.generic'] = {'#generics'}, - ['doc.generic.object'] = {'generic', 'extends'}, - ['doc.vararg'] = {'vararg'}, - ['doc.type.table'] = {'key', 'value'}, - ['doc.type.function'] = {'#args', '#returns'}, - ['doc.overload'] = {'overload'}, + ['doc.class'] = {'class', 'extends', 'comment'}, + ['doc.type'] = {'#types', '#enums', 'name', 'comment'}, + ['doc.alias'] = {'alias', 'extends', 'comment'}, + ['doc.param'] = {'param', 'extends', 'comment'}, + ['doc.return'] = {'#returns', 'comment'}, + ['doc.field'] = {'field', 'extends', 'comment'}, + ['doc.generic'] = {'#generics', 'comment'}, + ['doc.generic.object'] = {'generic', 'extends', 'comment'}, + ['doc.vararg'] = {'vararg', 'comment'}, + ['doc.type.table'] = {'key', 'value', 'comment'}, + ['doc.type.function'] = {'#args', '#returns', 'comment'}, + ['doc.overload'] = {'overload', 'comment'}, } m.actionMap = { diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 2b2396ec..53f0097d 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -856,19 +856,21 @@ local function buildLuaDoc(comment) comment = comment, } end - local finishPos = text:find('@', startPos + 1) - local doc, lastComment - if finishPos then - doc = text:sub(startPos + 1, finishPos - 1) - lastComment = text:sub(finishPos) - else - doc = text:sub(startPos + 1) - end + + local doc = text:sub(startPos + 1) parseTokens(doc, comment.start + startPos - 1) local result = convertTokens() if result then - result.comment = lastComment + local cstart = text:find('%S', result.finish - comment.start + 2) + if cstart and cstart < comment.finish then + result.comment = { + type = 'doc.tailcomment', + start = cstart + comment.start - 1, + finish = comment.finish, + text = text:sub(cstart), + } + end end return result |