chore: resolve undefined-field

This commit is contained in:
Alexander Courtis
2024-10-28 16:01:02 +11:00
parent 142cb30b3d
commit 4aba93b25e
7 changed files with 38 additions and 38 deletions

View File

@@ -178,14 +178,14 @@ local function custom(self, path)
end end
---Prepare arguments for should_filter. This is done prior to should_filter for efficiency reasons. ---Prepare arguments for should_filter. This is done prior to should_filter for efficiency reasons.
---@param git_status table|nil optional results of git.load_project(...) ---@param project GitProject? optional results of git.load_projects(...)
---@return table ---@return table
--- git_status: reference --- git_status: reference
--- bufinfo: empty unless no_buffer set: vim.fn.getbufinfo { buflisted = 1 } --- bufinfo: empty unless no_buffer set: vim.fn.getbufinfo { buflisted = 1 }
--- bookmarks: absolute paths to boolean --- bookmarks: absolute paths to boolean
function Filters:prepare(git_status) function Filters:prepare(project)
local status = { local status = {
git_status = git_status or {}, git_status = project or {},
bufinfo = {}, bufinfo = {},
bookmarks = {}, bookmarks = {},
} }

View File

@@ -187,9 +187,9 @@ function Explorer:expand(node)
end end
---@param node DirectoryNode ---@param node DirectoryNode
---@param git_status table|nil ---@param project GitProject?
---@return Node[]? ---@return Node[]?
function Explorer:reload(node, git_status) function Explorer:reload(node, project)
local cwd = node.link_to or node.absolute_path local cwd = node.link_to or node.absolute_path
local handle = vim.loop.fs_scandir(cwd) local handle = vim.loop.fs_scandir(cwd)
if not handle then if not handle then
@@ -198,7 +198,7 @@ function Explorer:reload(node, git_status)
local profile = log.profile_start("reload %s", node.absolute_path) local profile = log.profile_start("reload %s", node.absolute_path)
local filter_status = self.filters:prepare(git_status) local filter_status = self.filters:prepare(project)
if node.group_next then if node.group_next then
node.nodes = { node.group_next } node.nodes = { node.group_next }
@@ -268,7 +268,7 @@ function Explorer:reload(node, git_status)
end end
node.nodes = vim.tbl_map( node.nodes = vim.tbl_map(
self:update_status(nodes_by_path, node_ignored, git_status), self:update_git_statuses(nodes_by_path, node_ignored, project),
vim.tbl_filter(function(n) vim.tbl_filter(function(n)
if remain_childs[n.absolute_path] then if remain_childs[n.absolute_path] then
return remain_childs[n.absolute_path] return remain_childs[n.absolute_path]
@@ -282,7 +282,7 @@ function Explorer:reload(node, git_status)
local single_child = node:single_child_directory() local single_child = node:single_child_directory()
if config.renderer.group_empty and node.parent and single_child then if config.renderer.group_empty and node.parent and single_child then
node.group_next = single_child node.group_next = single_child
local ns = self:reload(single_child, git_status) local ns = self:reload(single_child, project)
node.nodes = ns or {} node.nodes = ns or {}
log.profile_end(profile) log.profile_end(profile)
return ns return ns
@@ -331,19 +331,19 @@ end
---@param node DirectoryNode ---@param node DirectoryNode
function Explorer:_load(node) function Explorer:_load(node)
local cwd = node.link_to or node.absolute_path local cwd = node.link_to or node.absolute_path
local git_status = git.load_project(cwd) local project = git.load_project(cwd)
self:explore(node, git_status, self) self:explore(node, project, self)
end end
---@private ---@private
---@param nodes_by_path Node[] ---@param nodes_by_path Node[]
---@param node_ignored boolean ---@param node_ignored boolean
---@param status table|nil ---@param project GitProject?
---@return fun(node: Node): table ---@return fun(node: Node): table
function Explorer:update_status(nodes_by_path, node_ignored, status) function Explorer:update_git_statuses(nodes_by_path, node_ignored, project)
return function(node) return function(node)
if nodes_by_path[node.absolute_path] then if nodes_by_path[node.absolute_path] then
node:update_git_status(node_ignored, status) node:update_git_status(node_ignored, project)
end end
return node return node
end end
@@ -353,13 +353,13 @@ end
---@param handle uv.uv_fs_t ---@param handle uv.uv_fs_t
---@param cwd string ---@param cwd string
---@param node DirectoryNode ---@param node DirectoryNode
---@param git_status table ---@param project GitProject
---@param parent Explorer ---@param parent Explorer
function Explorer:populate_children(handle, cwd, node, git_status, parent) function Explorer:populate_children(handle, cwd, node, project, parent)
local node_ignored = node:is_git_ignored() local node_ignored = node:is_git_ignored()
local nodes_by_path = utils.bool_record(node.nodes, "absolute_path") local nodes_by_path = utils.bool_record(node.nodes, "absolute_path")
local filter_status = parent.filters:prepare(git_status) local filter_status = parent.filters:prepare(project)
node.hidden_stats = vim.tbl_deep_extend("force", node.hidden_stats or {}, { node.hidden_stats = vim.tbl_deep_extend("force", node.hidden_stats or {}, {
git = 0, git = 0,
@@ -388,7 +388,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
if child then if child then
table.insert(node.nodes, child) table.insert(node.nodes, child)
nodes_by_path[child.absolute_path] = true nodes_by_path[child.absolute_path] = true
child:update_git_status(node_ignored, git_status) child:update_git_status(node_ignored, project)
end end
else else
for reason, value in pairs(FILTER_REASON) do for reason, value in pairs(FILTER_REASON) do
@@ -405,10 +405,10 @@ end
---@private ---@private
---@param node DirectoryNode ---@param node DirectoryNode
---@param status table ---@param project GitProject
---@param parent Explorer ---@param parent Explorer
---@return Node[]|nil ---@return Node[]|nil
function Explorer:explore(node, status, parent) function Explorer:explore(node, project, parent)
local cwd = node.link_to or node.absolute_path local cwd = node.link_to or node.absolute_path
local handle = vim.loop.fs_scandir(cwd) local handle = vim.loop.fs_scandir(cwd)
if not handle then if not handle then
@@ -417,15 +417,15 @@ function Explorer:explore(node, status, parent)
local profile = log.profile_start("explore %s", node.absolute_path) local profile = log.profile_start("explore %s", node.absolute_path)
self:populate_children(handle, cwd, node, status, parent) self:populate_children(handle, cwd, node, project, parent)
local is_root = not node.parent local is_root = not node.parent
local single_child = node:single_child_directory() local single_child = node:single_child_directory()
if config.renderer.group_empty and not is_root and single_child then if config.renderer.group_empty and not is_root and single_child then
local child_cwd = single_child.link_to or single_child.absolute_path local child_cwd = single_child.link_to or single_child.absolute_path
local child_status = git.load_project(child_cwd) local child_project = git.load_project(child_cwd)
node.group_next = single_child node.group_next = single_child
local ns = self:explore(single_child, child_status, parent) local ns = self:explore(single_child, child_project, parent)
node.nodes = ns or {} node.nodes = ns or {}
log.profile_end(profile) log.profile_end(profile)
@@ -440,7 +440,7 @@ function Explorer:explore(node, status, parent)
end end
---@private ---@private
---@param projects table ---@param projects GitProject[]
function Explorer:refresh_nodes(projects) function Explorer:refresh_nodes(projects)
Iterator.builder({ self }) Iterator.builder({ self })
:applier(function(n) :applier(function(n)

View File

@@ -38,9 +38,9 @@ end
---Update the directory git_status of link target and the file status of the link itself ---Update the directory git_status of link target and the file status of the link itself
---@param parent_ignored boolean ---@param parent_ignored boolean
---@param status table|nil ---@param project GitProject?
function DirectoryLinkNode:update_git_status(parent_ignored, status) function DirectoryLinkNode:update_git_status(parent_ignored, project)
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.link_to, self.absolute_path) self.git_status = git_utils.git_status_dir(parent_ignored, project, self.link_to, self.absolute_path)
end end
---Create a sanitized partial copy of a node, populating children recursively. ---Create a sanitized partial copy of a node, populating children recursively.

View File

@@ -67,9 +67,9 @@ end
---Update the git_status of the directory ---Update the git_status of the directory
---@param parent_ignored boolean ---@param parent_ignored boolean
---@param status table|nil ---@param project GitProject?
function DirectoryNode:update_git_status(parent_ignored, status) function DirectoryNode:update_git_status(parent_ignored, project)
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.absolute_path, nil) self.git_status = git_utils.git_status_dir(parent_ignored, project, self.absolute_path, nil)
end end
---@return GitXY[]? ---@return GitXY[]?

View File

@@ -34,9 +34,9 @@ end
---Update the git_status of the target otherwise the link itself ---Update the git_status of the target otherwise the link itself
---@param parent_ignored boolean ---@param parent_ignored boolean
---@param status table|nil ---@param project GitProject?
function FileLinkNode:update_git_status(parent_ignored, status) function FileLinkNode:update_git_status(parent_ignored, project)
self.git_status = git_utils.git_status_file(parent_ignored, status, self.link_to, self.absolute_path) self.git_status = git_utils.git_status_file(parent_ignored, project, self.link_to, self.absolute_path)
end end
---Create a sanitized partial copy of a node ---Create a sanitized partial copy of a node

View File

@@ -42,9 +42,9 @@ end
---Update the GitStatus of the file ---Update the GitStatus of the file
---@param parent_ignored boolean ---@param parent_ignored boolean
---@param status table|nil ---@param project GitProject?
function FileNode:update_git_status(parent_ignored, status) function FileNode:update_git_status(parent_ignored, project)
self.git_status = git_utils.git_status_file(parent_ignored, status, self.absolute_path, nil) self.git_status = git_utils.git_status_file(parent_ignored, project, self.absolute_path, nil)
end end
---@return GitXY[]? ---@return GitXY[]?

View File

@@ -22,9 +22,9 @@ end
---Update the git_status of the node ---Update the git_status of the node
---Abstract ---Abstract
---@param parent_ignored boolean ---@param parent_ignored boolean
---@param status table? ---@param project GitProject?
function Node:update_git_status(parent_ignored, status) function Node:update_git_status(parent_ignored, project)
self:nop(parent_ignored, status) self:nop(parent_ignored, project)
end end
---Short-format statuses ---Short-format statuses