summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-18 18:33:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-18 18:33:14 +0800
commitef7c96bfd7b57dd2a741c107e823bc59e4f2b87c (patch)
treecaa8af4f3ddaf07128a1b9d5a3d7c270b639ee7c /server/src
parent09064478af8fff383fd188d3b38461563f32968a (diff)
downloadlua-language-server-ef7c96bfd7b57dd2a741c107e823bc59e4f2b87c.zip
优化不定参函数的hover
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/diagnostics.lua3
-rw-r--r--server/src/matcher/hover.lua25
-rw-r--r--server/src/matcher/vm.lua2
3 files changed, 22 insertions, 8 deletions
diff --git a/server/src/matcher/diagnostics.lua b/server/src/matcher/diagnostics.lua
index e7dfb533..7a190354 100644
--- a/server/src/matcher/diagnostics.lua
+++ b/server/src/matcher/diagnostics.lua
@@ -137,6 +137,9 @@ end
local function searchRedundantParameters(results, callback)
for _, call in ipairs(results.calls) do
+ if not call.func.built then
+ goto NEXT_CALL
+ end
if call.func.hasDots then
goto NEXT_CALL
end
diff --git a/server/src/matcher/hover.lua b/server/src/matcher/hover.lua
index 41dccd39..911cf964 100644
--- a/server/src/matcher/hover.lua
+++ b/server/src/matcher/hover.lua
@@ -209,11 +209,7 @@ local function buildValueArgs(result, source)
local values = {}
if func.args then
for i, arg in ipairs(func.args) do
- if arg.type == '...' then
- names[i] = '...'
- else
- names[i] = arg.key
- end
+ names[i] = arg.key
end
end
if func.argValues then
@@ -226,10 +222,23 @@ local function buildValueArgs(result, source)
if source.object then
start = 2
end
- for i = start, math.max(#names, #values) do
- local name = names[i] or '?'
+ local max
+ if func.built then
+ max = #names
+ else
+ max = math.max(#names, #values)
+ end
+ for i = start, max do
+ local name = names[i]
local value = values[i] or 'any'
- strs[#strs+1] = name .. ': ' .. value
+ if name then
+ strs[#strs+1] = name .. ': ' .. value
+ else
+ strs[#strs+1] = value
+ end
+ end
+ if func.hasDots then
+ strs[#strs+1] = '...'
end
return table.concat(strs, ', ')
end
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index aade0f92..0633934d 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -253,6 +253,8 @@ function mt:buildFunction(exp, object)
return func
end
+ func.built = true
+
self.scope:push()
self.chunk:push()
self.chunk:cut 'dots'