restored behavior removing self/cls argument for func in class

This commit is contained in:
Chris Brendel
2023-01-12 15:27:55 -05:00
parent 41fe4ba304
commit 56620c0191

View File

@@ -50,7 +50,7 @@ return {
retrieve = "all", retrieve = "all",
node_type = "typed_default_parameter", node_type = "typed_default_parameter",
as = i.Tparam, as = i.Tparam,
extract = true extract = true,
}, },
{ {
retrieve = "first", retrieve = "first",
@@ -127,7 +127,7 @@ return {
-- Check if the function is inside a class -- Check if the function is inside a class
-- If so, remove reference to the first parameter (that can be `self`, `cls`, or a custom name) -- If so, remove reference to the first parameter (that can be `self`, `cls`, or a custom name)
if res.identifier and locator({ current = node }, parent.class) then if res.parameters and locator({ current = node }, parent.class) then
local remove_identifier = true local remove_identifier = true
-- Check if function is a static method. If so, will not remove the first parameter -- Check if function is a static method. If so, will not remove the first parameter
if node:parent():type() == "decorated_definition" then if node:parent():type() == "decorated_definition" then
@@ -138,9 +138,9 @@ return {
end end
end end
if remove_identifier then if remove_identifier then
table.remove(res.identifier, 1) table.remove(res.parameters, 1)
if vim.tbl_isempty(res.identifier) then if vim.tbl_isempty(res.parameters) then
res.identifier = nil res.parameters = nil
end end
end end
end end