diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-03 11:39:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-03 11:39:58 +0800 |
commit | d5634992993466a2fe309321ed6919ec5eeeb99c (patch) | |
tree | 651a656c6c1e4305bbf06afd9a9fb0cae8c4de88 | |
parent | 34aee7e51edcd526ff8be51882e403af41435cb5 (diff) | |
download | lua-language-server-d5634992993466a2fe309321ed6919ec5eeeb99c.zip |
improve performance of hint
-rw-r--r-- | script/core/hint.lua | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/script/core/hint.lua b/script/core/hint.lua index df191b9c..aa39812f 100644 --- a/script/core/hint.lua +++ b/script/core/hint.lua @@ -71,6 +71,18 @@ local function getArgNames(func) return names end +local function hasLiteralArgInCall(call) + if not call.args then + return false + end + for _, arg in ipairs(call.args) do + if guide.isLiteral(arg) then + return true + end + end + return false +end + local function paramName(uri, edits, start, finish) if not config.config.hint.paramName then return @@ -83,7 +95,7 @@ local function paramName(uri, edits, start, finish) if source.type ~= 'call' then return end - if not source.args then + if not hasLiteralArgInCall(source) then return end local defs = vm.getDefs(source.node, 0) @@ -109,12 +121,7 @@ local function paramName(uri, edits, start, finish) table.remove(args, 1) end for i, arg in ipairs(source.args) do - if arg.type == 'nil' - or arg.type == 'number' - or arg.type == 'string' - or arg.type == 'boolean' - or arg.type == 'table' - or arg.type == 'function' then + if guide.isLiteral(arg) then if args[i] and args[i] ~= '' then edits[#edits+1] = { newText = ('%s:'):format(args[i]), |