diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-31 10:42:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-31 10:42:27 +0800 |
commit | 51a43979dc277e1a4418725cd001b5520d84588d (patch) | |
tree | eefbf7dc228820ff9aea59134022a0bbe5ecf7e5 /script/parser | |
parent | d36ceb32aeb95261be630157cbf7389c0d3c8085 (diff) | |
download | lua-language-server-51a43979dc277e1a4418725cd001b5520d84588d.zip |
#450 add dummy param into param list
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/ast.lua | 14 | ||||
-rw-r--r-- | script/parser/compile.lua | 41 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 4 |
3 files changed, 33 insertions, 26 deletions
diff --git a/script/parser/ast.lua b/script/parser/ast.lua index 9acdb06b..45801cf6 100644 --- a/script/parser/ast.lua +++ b/script/parser/ast.lua @@ -6,7 +6,6 @@ local mathType = math.type local tableRemove = table.remove local pairs = pairs local tableSort = table.sort -local tableInsert = table.insert _ENV = nil @@ -702,14 +701,6 @@ local Defs = { finish = call.finish, } end - if call.type == 'call' - and call.node - and call.node.type == 'getmethod' then - if not call.args then - call.args = {} - end - tableInsert(call.args, 1, call.node) - end return call end, BinaryOp = function (start, op) @@ -1026,11 +1017,6 @@ local Defs = { elseif name.type == 'getmethod' then name.type = 'setmethod' name.value = actions - if not args then - args = {} - actions.args = args - end - tableInsert(args, 1, name.node) elseif name.type == 'getindex' then name.type = 'setfield' name.value = actions diff --git a/script/parser/compile.lua b/script/parser/compile.lua index 392f0682..04fc19c7 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -1,6 +1,8 @@ -local guide = require 'core.guide' -local type = type -local os = os +local guide = require 'parser.guide' +local type = type +local tableInsert = table.insert +local pairs = pairs +local os = os local specials = { ['_G'] = true, @@ -73,6 +75,24 @@ local vmMap = { end, ['call'] = function (obj) Compile(obj.node, obj) + if obj.node and obj.node.type == 'getmethod' then + if not obj.args then + obj.args = { + type = 'callargs', + start = obj.start, + finish = obj.finish, + parent = obj, + } + end + local newNode = {} + for k, v in pairs(obj.node.node) do + newNode[k] = v + end + newNode.mirror = obj.node.node + newNode.dummy = true + obj.node.node.mirror = newNode + tableInsert(obj.args, 1, newNode) + end Compile(obj.args, obj) end, ['callargs'] = function (obj) @@ -126,15 +146,24 @@ local vmMap = { Compile(obj.node, obj) Compile(obj.method, obj) local value = obj.value - value.localself = { + local localself = { type = 'local', start = 0, finish = 0, method = obj, effect = obj.finish, tag = 'self', + dummy = true, [1] = 'self', } + if not value.args then + value.args = { + type = 'funcargs', + start = obj.start, + finish = obj.finish, + } + end + tableInsert(value.args, 1, localself) Compile(value, obj) end, ['function'] = function (obj) @@ -142,10 +171,6 @@ local vmMap = { local LastLocalCount = LocalCount Block = obj LocalCount = 0 - if obj.localself then - Compile(obj.localself, obj) - obj.localself = nil - end Compile(obj.args, obj) for i = 1, #obj do Compile(obj[i], obj) diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 7e133aa2..74e53718 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -1148,10 +1148,6 @@ local function bindParamAndReturnIndex(binded) return end local paramIndex = 0 - local parent = func.parent - if parent.type == 'setmethod' then - paramIndex = paramIndex + 1 - end local paramMap = {} for _, param in ipairs(func.args) do paramIndex = paramIndex + 1 |