add classic, migrating nodes classes

This commit is contained in:
Alexander Courtis
2024-11-04 13:17:33 +11:00
parent 610a1c189b
commit 35015149e2
11 changed files with 181 additions and 138 deletions

View File

@@ -15,35 +15,28 @@ local PICTURE_MAP = {
---@class (exact) FileNode: Node
---@field extension string
local FileNode = Node:new()
local FileNode = Node:extend()
---Static factory method
---@param explorer Explorer
---@param parent DirectoryNode
---@param absolute_path string
---@param name string
---@param fs_stat uv.fs_stat.result?
---@return FileNode
function FileNode:create(explorer, parent, absolute_path, name, fs_stat)
---@type FileNode
local o = {
type = "file",
explorer = explorer,
absolute_path = absolute_path,
executable = utils.is_executable(absolute_path),
fs_stat = fs_stat,
git_status = nil,
hidden = false,
name = name,
parent = parent,
diag_status = nil,
is_dot = false,
function FileNode:new(explorer, parent, absolute_path, name, fs_stat)
FileNode.super.new(self)
extension = string.match(name, ".?[^.]+%.(.*)") or "",
}
o = self:new(o)
self.type = "file"
self.explorer = explorer
self.absolute_path = absolute_path
self.executable = utils.is_executable(absolute_path)
self.fs_stat = fs_stat
self.git_status = nil
self.hidden = false
self.name = name
self.parent = parent
self.diag_status = nil
return o
self.extension = string.match(name, ".?[^.]+%.(.*)") or ""
end
function FileNode:destroy()