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",
node_type = "typed_default_parameter",
as = i.Tparam,
extract = true
extract = true,
},
{
retrieve = "first",
@@ -127,7 +127,7 @@ return {
-- 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 res.identifier and locator({ current = node }, parent.class) then
if res.parameters and locator({ current = node }, parent.class) then
local remove_identifier = true
-- Check if function is a static method. If so, will not remove the first parameter
if node:parent():type() == "decorated_definition" then
@@ -138,9 +138,9 @@ return {
end
end
if remove_identifier then
table.remove(res.identifier, 1)
if vim.tbl_isempty(res.identifier) then
res.identifier = nil
table.remove(res.parameters, 1)
if vim.tbl_isempty(res.parameters) then
res.parameters = nil
end
end
end