diff options
author | sumneko <sumneko@hotmail.com> | 2022-03-06 21:40:34 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2022-03-06 21:40:34 +0800 |
commit | bd9566eb4c856d041e705be59e9b62b0a09d3ed4 (patch) | |
tree | 4e7454be8cd388a91c373b3ebf9cfe103455d39b /script/parser | |
parent | aa6703f8e866cbc2cb50740000ad6ca1e46dd860 (diff) | |
download | lua-language-server-bd9566eb4c856d041e705be59e9b62b0a09d3ed4.zip |
update
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/guide.lua | 11 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 32 |
2 files changed, 20 insertions, 23 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 831534a7..9be84e4e 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -128,12 +128,11 @@ local childMap = { ['doc.generic.object'] = {'generic', 'extends', 'comment'}, ['doc.vararg'] = {'vararg', 'comment'}, ['doc.type.array'] = {'node'}, - ['doc.type.table'] = {'tkey', 'tvalue', 'comment'}, ['doc.type.function'] = {'#args', '#returns', 'comment'}, - ['doc.type.ltable'] = {'#fields', 'comment'}, + ['doc.type.table'] = {'#fields', 'comment'}, ['doc.type.literal'] = {'node'}, ['doc.type.arg'] = {'name', 'extends'}, - ['doc.type.field'] = {'extends'}, + ['doc.type.field'] = {'name', 'extends'}, ['doc.overload'] = {'overload', 'comment'}, ['doc.see'] = {'name', 'field'}, ['doc.version'] = {'#versions'}, @@ -885,17 +884,17 @@ function m.getKeyNameOfLiteral(obj) elseif tp == 'number' then local n = obj[1] if n then - return formatNumber(obj[1]) + return obj[1] end elseif tp == 'integer' then local n = obj[1] if n then - return formatNumber(obj[1]) + return obj[1] end elseif tp == 'boolean' then local b = obj[1] if b then - return tostring(b) + return b end end end diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index ccc38eac..d516643b 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -223,25 +223,24 @@ local function parseIndexField(tp, parent) return nil end nextToken() - local class = { - type = tp, - start = getStart(), - finish = getFinish(), - parent = parent, - } - local indexTP, index = nextToken() - if indexTP ~= 'integer' - and indexTP ~= 'string' then - pushWarning { - type = 'LUADOC_INDEX_MUST_INT', + local indexTP, index = peekToken() + if indexTP == 'name' then + local field = parseType(parent) + nextSymbolOrError ']' + return field + else + nextToken() + local class = { + type = tp, start = getStart(), finish = getFinish(), + parent = parent, } + class[1] = index + nextSymbolOrError ']' + class.finish = getFinish() + return class end - class[1] = index - nextSymbolOrError ']' - class.finish = getFinish() - return class end local function parseClass(parent) @@ -427,7 +426,7 @@ end local function parseTypeUnitLiteralTable() local typeUnit = { - type = 'doc.type.ltable', + type = 'doc.type.table', start = getStart(), fields = {}, } @@ -527,7 +526,6 @@ function parseTypeUnit(parent, content) result.parent = parent while true do local newResult = parseTypeUnitArray(parent, result) - or parseTypeUnitTable(parent, result) if not newResult then break end |