diff options
author | AlexCai2019 <89138532+AlexCai2019@users.noreply.github.com> | 2022-05-08 01:43:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 01:43:28 +0800 |
commit | 0fd83c4ca9f82a02becab6c304a8a7de75098507 (patch) | |
tree | be9790d9d4823fe728c5b36e94093fe5f42b7725 /script/parser/newparser.lua | |
parent | 89203efad8c9b5513e05ca4d5696107924865b10 (diff) | |
parent | 67b4c574849d1667e0ecb39c51aeed8e30b43056 (diff) | |
download | lua-language-server-0fd83c4ca9f82a02becab6c304a8a7de75098507.zip |
Merge branch 'sumneko:master' into master
Diffstat (limited to 'script/parser/newparser.lua')
-rw-r--r-- | script/parser/newparser.lua | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index e226417f..630c12c2 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -117,6 +117,7 @@ local Specials = { ['xpcall'] = true, ['pairs'] = true, ['ipairs'] = true, + ['assert'] = true, } local UnarySymbol = { @@ -537,6 +538,7 @@ local function skipComment(isAction) if longComment then longComment.type = 'comment.long' longComment.text = longComment[1] + longComment.mark = longComment[2] longComment[1] = nil longComment[2] = nil State.comms[#State.comms+1] = longComment @@ -689,9 +691,6 @@ local function parseLocalAttrs() end local function createLocal(obj, attrs) - if not obj then - return nil - end obj.type = 'local' obj.effect = obj.finish @@ -2891,7 +2890,11 @@ local function parseLocal() pushActionIntoCurrentChunk(loc) skipSpace() parseMultiVars(loc, parseName, true) - loc.effect = lastRightPosition() + if loc.value then + loc.effect = loc.value.finish + else + loc.effect = loc.finish + end return loc end @@ -2946,13 +2949,22 @@ local function parseReturn() end pushActionIntoCurrentChunk(rtn) for i = #Chunk, 1, -1 do - local func = Chunk[i] - if func.type == 'function' - or func.type == 'main' then - if not func.returns then - func.returns = {} + local block = Chunk[i] + if block.type == 'function' + or block.type == 'main' then + if not block.returns then + block.returns = {} end - func.returns[#func.returns+1] = rtn + block.returns[#block.returns+1] = rtn + break + end + end + for i = #Chunk, 1, -1 do + local block = Chunk[i] + if block.type == 'ifblock' + or block.type == 'elseifblock' + or block.type == 'else' then + block.hasReturn = true break end end @@ -3052,6 +3064,15 @@ local function parseGoTo() break end end + for i = #Chunk, 1, -1 do + local chunk = Chunk[i] + if chunk.type == 'ifblock' + or chunk.type == 'elseifblock' + or chunk.type == 'elseblock' then + chunk.hasGoTo = true + break + end + end pushActionIntoCurrentChunk(action) return action @@ -3586,6 +3607,15 @@ local function parseBreak() break end end + for i = #Chunk, 1, -1 do + local chunk = Chunk[i] + if chunk.type == 'ifblock' + or chunk.type == 'elseifblock' + or chunk.type == 'elseblock' then + chunk.hasBreak = true + break + end + end if not ok and Mode == 'Lua' then pushError { type = 'BREAK_OUTSIDE', |