diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-10-26 17:32:42 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-10-26 17:32:42 +0800 |
commit | ae205d290868d51ba20947fac2817534e00e53cb (patch) | |
tree | 812c4c4fbd02b92674cb21dcdbc0923143ba7951 /script/parser | |
parent | 40e0d3595961913aff0405369ddc9cbec2f743d1 (diff) | |
download | lua-language-server-ae205d290868d51ba20947fac2817534e00e53cb.zip |
fix #760
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/newparser.lua | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index ca0bc66a..0b721a7a 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -1639,6 +1639,30 @@ local function parseTable() return tbl end +local function addDummySelf(node, call) + if node.type ~= 'getmethod' then + return + end + -- dummy param `self` + if not call.args then + call.args = { + type = 'callargs', + start = call.start, + finish = call.finish, + parent = call, + } + end + local newNode = {} + for k, v in next, call.node.node do + newNode[k] = v + end + newNode.mirror = call.node.node + newNode.dummy = true + newNode.parent = call.args + call.node.node.mirror = newNode + tinsert(call.args, 1, newNode) +end + local function parseSimple(node, funcName) local lastMethod while true do @@ -1740,26 +1764,7 @@ local function parseSimple(node, funcName) args.parent = call call.args = args end - if node.type == 'getmethod' then - -- dummy param `self` - if not call.args then - call.args = { - type = 'callargs', - start = call.start, - finish = call.finish, - parent = call, - } - end - local newNode = {} - for k, v in next, call.node.node do - newNode[k] = v - end - newNode.mirror = call.node.node - newNode.dummy = true - newNode.parent = call.args - call.node.node.mirror = newNode - tinsert(call.args, 1, newNode) - end + addDummySelf(node, call) node.parent = call node = call elseif token == '{' then @@ -1781,6 +1786,7 @@ local function parseSimple(node, funcName) [1] = tbl, } call.args = args + addDummySelf(node, call) tbl.parent = args node.parent = call node = call @@ -1803,6 +1809,7 @@ local function parseSimple(node, funcName) [1] = str, } call.args = args + addDummySelf(node, call) str.parent = args node.parent = call node = call @@ -1826,6 +1833,7 @@ local function parseSimple(node, funcName) [1] = str, } call.args = args + addDummySelf(node, call) str.parent = args node.parent = call node = call |