summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-28 10:57:43 +0800
committersumneko <sumneko@hotmail.com>2019-04-28 10:57:43 +0800
commit0e3fe7fe0c9d660d26a735b0d3d962f4c4289ca8 (patch)
treeee34982f01d594f19ce694001411194d8bcf7876 /server
parentfdbc780ec38812ad4f63dc1a5cbda2c0d07f7003 (diff)
downloadlua-language-server-0e3fe7fe0c9d660d26a735b0d3d962f4c4289ca8.zip
---@param的自动完成过滤掉self
Diffstat (limited to 'server')
-rw-r--r--server/src/core/completion.lua18
-rw-r--r--server/test/completion/init.lua28
2 files changed, 41 insertions, 5 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 3daf71d5..bf9b8d84 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -465,21 +465,29 @@ local function searchEmmyFunctionParam(vm, source, word, callback)
local list = {}
local args = {}
for i, arg in ipairs(func.args) do
- args[i] = arg.name
- if i == 1 then
- list[i] = ('%s any'):format(arg.name)
+ if func:getObject() and i == 1 then
+ goto NEXT
+ end
+ args[#args+1] = arg.name
+ if #list == 0 then
+ list[#list+1] = ('%s any'):format(arg.name)
else
- list[i] = ('---@param %s any'):format(arg.name)
+ list[#list+1] = ('---@param %s any'):format(arg.name)
end
+ :: NEXT ::
end
callback(('%s'):format(table.concat(args, ', ')), nil, CompletionItemKind.Snippet, {
insertText = table.concat(list, '\n')
})
end
- for _, arg in ipairs(func.args) do
+ for i, arg in ipairs(func.args) do
+ if func:getObject() and i == 1 then
+ goto NEXT
+ end
if matchKey(word, arg.name) then
callback(arg.name, nil, CompletionItemKind.Interface)
end
+ :: NEXT ::
end
end
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index eb30d9a0..6a3b6f29 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -872,6 +872,34 @@ a any
}
TEST [[
+---@param $
+function mt:f(a, b, c)
+end
+]]
+{
+ {
+ label = 'a, b, c',
+ kind = CompletionItemKind.Snippet,
+ insertText = [[
+a any
+---@param b any
+---@param c any]]
+ },
+ {
+ label = 'a',
+ kind = CompletionItemKind.Interface,
+ },
+ {
+ label = 'b',
+ kind = CompletionItemKind.Interface,
+ },
+ {
+ label = 'c',
+ kind = CompletionItemKind.Interface,
+ },
+}
+
+TEST [[
---@param xyz Class
---@param xxx Class
function f(x$)