Skip to content

Commit aba83cc

Browse files
committed
chore: resolve undefined-field
1 parent 8760d76 commit aba83cc

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

lua/nvim-tree/class.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ function Class:as(class)
3737
return self:is(class) and self or nil
3838
end
3939

40+
-- avoid unused param warnings in abstract methods
41+
---@param ... any
42+
function Class:nop(...)
43+
end
44+
4045
return Class

lua/nvim-tree/node/directory.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ function DirectoryNode:refresh()
139139
end)
140140
end
141141

142+
---@param projects table
143+
function DirectoryNode:reload_node_status(projects)
144+
local toplevel = git.get_toplevel(self.absolute_path)
145+
local status = projects[toplevel] or {}
146+
for _, node in ipairs(self.nodes) do
147+
node:update_git_status(self:is_git_ignored(), status)
148+
local dir = node:as(DirectoryNode)
149+
if dir and #dir.nodes > 0 then
150+
dir:reload_node_status(projects)
151+
end
152+
end
153+
end
154+
142155
-- If node is grouped, return the last node in the group. Otherwise, return the given node.
143156
---@return DirectoryNode
144157
function DirectoryNode:last_group_node()

lua/nvim-tree/node/init.lua

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,18 @@ local Node = Class:new()
2121
function Node:destroy()
2222
end
2323

24-
--luacheck: push ignore 212
2524
---Update the GitStatus of the node
25+
---Abstract
2626
---@param parent_ignored boolean
2727
---@param status table?
28-
function Node:update_git_status(parent_ignored, status) ---@diagnostic disable-line: unused-local
29-
---TODO find a way to declare abstract methods
28+
function Node:update_git_status(parent_ignored, status)
29+
self:nop(parent_ignored, status)
3030
end
3131

32-
--luacheck: pop
33-
3432
---@return GitStatus?
3533
function Node:get_git_status()
3634
end
3735

38-
---@param projects table
39-
function Node:reload_node_status(projects)
40-
local toplevel = git.get_toplevel(self.absolute_path)
41-
local status = projects[toplevel] or {}
42-
for _, node in ipairs(self.nodes) do
43-
node:update_git_status(self:is_git_ignored(), status)
44-
if node.nodes and #node.nodes > 0 then
45-
node:reload_node_status(projects)
46-
end
47-
end
48-
end
49-
5036
---@return boolean
5137
function Node:is_git_ignored()
5238
return self.git_status ~= nil and self.git_status.file == "!!"

0 commit comments

Comments
 (0)