diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-20 10:48:56 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-20 10:48:56 +0800 |
commit | 6700b36b52ffc9878b0d02cae2568fbc6716705e (patch) | |
tree | 9124b1285892244d6eeb17ce681eb3caddf0dc27 /server/src/parser/ast.lua | |
parent | 5364642437e6c7723e734d0f0aa2179a4b60159e (diff) | |
download | lua-language-server-6700b36b52ffc9878b0d02cae2568fbc6716705e.zip |
修正index中的局部变量没有正确识别的bug
Diffstat (limited to 'server/src/parser/ast.lua')
-rw-r--r-- | server/src/parser/ast.lua | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 3b397c0d..136d7565 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -629,8 +629,10 @@ local Defs = { end if isField then table[#table+1] = arg - wantField = false - start = arg.finish + 1 + if arg.finish then + wantField = false + start = arg.finish + 1 + end else wantField = true start = arg @@ -646,8 +648,7 @@ local Defs = { key, value, } end, - NewIndex = function (start, key, finish, value) - key.index = true + NewIndex = function (key, value) return { type = 'pair', start = key.start, @@ -1113,7 +1114,10 @@ local Defs = { [1] = '' } end, - EmmyClass = function (class, extends) + EmmyClass = function (class, startPos, extends) + if extends and extends[1] == '' then + extends.start = startPos + end return { type = 'emmyClass', start = class.start, @@ -1122,17 +1126,26 @@ local Defs = { [2] = extends, } end, - EmmyType = function (typeDef, ...) - if ... then - typeDef.enum = {...} - end + EmmyType = function (typeDef) return typeDef end, EmmyCommonType = function (...) - return { + local result = { type = 'emmyType', ... } + for i = 1, #result // 2 do + local startPos = result[i * 2] + local emmyName = result[i * 2 + 1] + if emmyName[1] == '' then + emmyName.start = startPos + end + result[i + 1] = emmyName + end + for i = #result // 2 + 2, #result do + result[i] = nil + end + return result end, EmmyArrayType = function (typeName) typeName.type = 'emmyArrayType' @@ -1145,23 +1158,26 @@ local Defs = { return typeName end, EmmyFunctionType = function (...) - return { + local result = { type = 'emmyFunctionType', ... } + return result end, - EmmyAlias = function (name, emmyName) + EmmyAlias = function (name, emmyName, ...) return { type = 'emmyAlias', - [1] = name, - [2] = emmyName, + name, + emmyName, + ... } end, - EmmyParam = function (argName, emmyName) + EmmyParam = function (argName, emmyName, ...) return { type = 'emmyParam', - [1] = argName, - [2] = emmyName, + argName, + emmyName, + ... } end, EmmyReturn = function (...) |