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/luadoc.lua | |
parent | dcca81c4fa7bd9b745123be8be0c8b07fcd6e29a (diff) | |
download | lua-language-server-9be846d86c494e08d376aa465e8269796176765a.zip |
type check: check the fields in table
resolve #1434
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r-- | script/parser/luadoc.lua | 28 |
1 files changed, 6 insertions, 22 deletions
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', |