diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-10 17:18:12 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-10 17:18:12 +0800 |
commit | b1f2b789ac1271f2a270253a086bae377bbb14cb (patch) | |
tree | 97f645b0298a4ebdd896b35f0db4e853832e5900 /script-beta/parser | |
parent | e1fac82828bedc20c123b0eb88f34223252db3b4 (diff) | |
download | lua-language-server-b1f2b789ac1271f2a270253a086bae377bbb14cb.zip |
换个做法
Diffstat (limited to 'script-beta/parser')
-rw-r--r-- | script-beta/parser/guide.lua | 8 | ||||
-rw-r--r-- | script-beta/parser/luadoc.lua | 49 |
2 files changed, 46 insertions, 11 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index cbb64cf4..8058328c 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -2625,6 +2625,14 @@ function m.getDocTypeNames(status, doc, genericCallback) source = enum, } end + if doc.resumes then + for _, resume in ipairs(doc.resumes) do + results[#results+1] = { + type = resume[1], + source = resume, + } + end + end return results end diff --git a/script-beta/parser/luadoc.lua b/script-beta/parser/luadoc.lua index 59d2e9b9..05dfcbe6 100644 --- a/script-beta/parser/luadoc.lua +++ b/script-beta/parser/luadoc.lua @@ -53,6 +53,7 @@ Symbol <- ({} { / '(' / ')' / '?' + / '#' } {}) -> Symbol ]], { @@ -110,8 +111,9 @@ Symbol <- ({} { end, }) -local function parseTokens(text) +local function parseTokens(text, offset) Ci = 0 + Offset = offset TokenTypes = {} TokenStarts = {} TokenFinishs = {} @@ -623,6 +625,26 @@ local function parseOverload() return result end +local function parseResume() + local result = { + type = 'doc.resume' + } + local tp = peekToken() + if tp ~= 'string' then + pushError { + type = 'LUADOC_MISS_STRING', + start = getFinish(), + finish = getFinish(), + } + return nil + end + local _, str = nextToken() + result[1] = str + result.start = getStart() + result.finish = getFinish() + return result +end + local function convertTokens() local tp, text = nextToken() if not tp then @@ -658,7 +680,6 @@ local function convertTokens() end local function buildLuaDoc(comment, nextComment) - Offset = comment.start + 1 local text = comment.text if text:sub(1, 1) ~= '-' then return @@ -680,24 +701,30 @@ local function buildLuaDoc(comment, nextComment) doc = text:sub(3) end - local finish = comment.start + #doc + 2 + parseTokens(doc, comment.start + 1) + local result = convertTokens() + if result then + result.comment = lastComment + end + while true do local nextComm = nextComment('peek') if nextComm and nextComm.text:sub(1, 2) == '-|' then nextComment() - local hold = nextComm.start - finish + 1 - doc = doc .. (' '):rep(hold) .. nextComm.text:sub(2) - finish = nextComm.finish + 1 + if not result.resumes then + result.resumes = {} + end + parseTokens(nextComm.text:sub(3), nextComm.start + 1) + local resume = parseResume() + if resume then + result.resumes[#result.resumes+1] = resume + result.finish = resume.finish + end else break end end - parseTokens(doc) - local result = convertTokens() - if result then - result.comment = lastComment - end return result end |