diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-11-06 22:58:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-11-06 22:58:11 +0800 |
commit | 9be846d86c494e08d376aa465e8269796176765a (patch) | |
tree | 04027cdb5ae6a118739a92911dbbd6797a39939f /script/parser | |
parent | dcca81c4fa7bd9b745123be8be0c8b07fcd6e29a (diff) | |
download | lua-language-server-9be846d86c494e08d376aa465e8269796176765a.zip |
type check: check the fields in table
resolve #1434
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/guide.lua | 4 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 28 |
2 files changed, 7 insertions, 25 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index f7dcc116..b6dbd65c 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -166,7 +166,7 @@ local childMap = { ['doc.as'] = {'as'}, ['doc.cast'] = {'loc', '#casts'}, ['doc.cast.block'] = {'extends'}, - ['doc.operator'] = {'op', 'exp', 'extends'} + ['doc.operator'] = {'op', 'exp', 'extends'}, } ---@type table<string, fun(obj: parser.object, list: parser.object[])> @@ -1027,8 +1027,6 @@ function m.getKeyName(obj) return obj.field[1] elseif tp == 'doc.field.name' then return obj[1] - elseif tp == 'doc.type.field' then - return obj.name[1] end return m.getKeyNameOfLiteral(obj) end diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 264c2535..6e0da3cc 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -250,30 +250,14 @@ local function nextSymbolOrError(symbol) return false end -local function parseIndexField(tp, parent) +local function parseIndexField(parent) if not checkToken('symbol', '[', 1) then return nil end nextToken() - local start = getFinish() - 1 - local indexTP, index = peekToken() - if indexTP == 'name' then - local field = parseType(parent) - nextSymbolOrError ']' - return field - else - nextToken() - local class = { - type = tp, - start = start, - finish = getFinish(), - parent = parent, - } - class[1] = index - nextSymbolOrError ']' - class.finish = getFinish() - return class - end + local field = parseType(parent) + nextSymbolOrError ']' + return field end local function parseTable(parent) @@ -305,7 +289,7 @@ local function parseTable(parent) needCloseParen = true end field.name = parseName('doc.field.name', field) - or parseIndexField('doc.field.name', field) + or parseIndexField(field) if not field.name then pushWarning { type = 'LUADOC_MISS_FIELD_NAME', @@ -1012,7 +996,7 @@ local docSwitch = util.switch() return false end) result.field = parseName('doc.field.name', result) - or parseIndexField('doc.field.name', result) + or parseIndexField(result) if not result.field then pushWarning { type = 'LUADOC_MISS_FIELD_NAME', |