chore: resolve undefined-field
This commit is contained in:
@@ -37,4 +37,9 @@ function Class:as(class)
|
|||||||
return self:is(class) and self or nil
|
return self:is(class) and self or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- avoid unused param warnings in abstract methods
|
||||||
|
---@param ... any
|
||||||
|
function Class:nop(...)
|
||||||
|
end
|
||||||
|
|
||||||
return Class
|
return Class
|
||||||
|
|||||||
@@ -139,6 +139,19 @@ function DirectoryNode:refresh()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param projects table
|
||||||
|
function DirectoryNode:reload_node_status(projects)
|
||||||
|
local toplevel = git.get_toplevel(self.absolute_path)
|
||||||
|
local status = projects[toplevel] or {}
|
||||||
|
for _, node in ipairs(self.nodes) do
|
||||||
|
node:update_git_status(self:is_git_ignored(), status)
|
||||||
|
local dir = node:as(DirectoryNode)
|
||||||
|
if dir and #dir.nodes > 0 then
|
||||||
|
dir:reload_node_status(projects)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- If node is grouped, return the last node in the group. Otherwise, return the given node.
|
-- If node is grouped, return the last node in the group. Otherwise, return the given node.
|
||||||
---@return DirectoryNode
|
---@return DirectoryNode
|
||||||
function DirectoryNode:last_group_node()
|
function DirectoryNode:last_group_node()
|
||||||
|
|||||||
@@ -21,32 +21,18 @@ local Node = Class:new()
|
|||||||
function Node:destroy()
|
function Node:destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
--luacheck: push ignore 212
|
|
||||||
---Update the GitStatus of the node
|
---Update the GitStatus of the node
|
||||||
|
---Abstract
|
||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table?
|
---@param status table?
|
||||||
function Node:update_git_status(parent_ignored, status) ---@diagnostic disable-line: unused-local
|
function Node:update_git_status(parent_ignored, status)
|
||||||
---TODO find a way to declare abstract methods
|
self:nop(parent_ignored, status)
|
||||||
end
|
end
|
||||||
|
|
||||||
--luacheck: pop
|
|
||||||
|
|
||||||
---@return GitStatus?
|
---@return GitStatus?
|
||||||
function Node:get_git_status()
|
function Node:get_git_status()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param projects table
|
|
||||||
function Node:reload_node_status(projects)
|
|
||||||
local toplevel = git.get_toplevel(self.absolute_path)
|
|
||||||
local status = projects[toplevel] or {}
|
|
||||||
for _, node in ipairs(self.nodes) do
|
|
||||||
node:update_git_status(self:is_git_ignored(), status)
|
|
||||||
if node.nodes and #node.nodes > 0 then
|
|
||||||
node:reload_node_status(projects)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Node:is_git_ignored()
|
function Node:is_git_ignored()
|
||||||
return self.git_status ~= nil and self.git_status.file == "!!"
|
return self.git_status ~= nil and self.git_status.file == "!!"
|
||||||
|
|||||||
Reference in New Issue
Block a user