Skip to content

Commit 8b313ab

Browse files
committed
BaseNode -> Node
1 parent 579fc7b commit 8b313ab

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

lua/nvim-tree/node/directory.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
local git = require("nvim-tree.git")
22
local watch = require("nvim-tree.explorer.watch")
33

4-
local BaseNode = require("nvim-tree.node")
4+
local Node = require("nvim-tree.node")
55

6-
---@class (exact) DirectoryNode: BaseNode
6+
---@class (exact) DirectoryNode: Node
77
---@field has_children boolean
88
---@field group_next DirectoryNode? -- If node is grouped, this points to the next child dir/link node
99
---@field nodes Node[]
1010
---@field open boolean
1111
---@field hidden_stats table? -- Each field of this table is a key for source and value for count
12-
local DirectoryNode = BaseNode:new()
12+
local DirectoryNode = Node:new()
1313

1414
---Static factory method
1515
---@param explorer Explorer
@@ -51,7 +51,7 @@ function DirectoryNode:create(explorer, parent, absolute_path, name, fs_stat)
5151
end
5252

5353
function DirectoryNode:destroy()
54-
BaseNode.destroy(self)
54+
Node.destroy(self)
5555
if self.nodes then
5656
for _, node in pairs(self.nodes) do
5757
node:destroy()
@@ -220,7 +220,7 @@ end
220220
---Create a sanitized partial copy of a node, populating children recursively.
221221
---@return DirectoryNode cloned
222222
function DirectoryNode:clone()
223-
local clone = BaseNode.clone(self) --[[@as DirectoryNode]]
223+
local clone = Node.clone(self) --[[@as DirectoryNode]]
224224

225225
clone.has_children = self.has_children
226226
clone.group_next = nil

lua/nvim-tree/node/file.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
local git = require("nvim-tree.git")
22
local utils = require("nvim-tree.utils")
33

4-
local BaseNode = require("nvim-tree.node")
4+
local Node = require("nvim-tree.node")
55

6-
---@class (exact) FileNode: BaseNode
6+
---@class (exact) FileNode: Node
77
---@field extension string
8-
local FileNode = BaseNode:new()
8+
local FileNode = Node:new()
99

1010
---Static factory method
1111
---@param explorer Explorer
@@ -56,7 +56,7 @@ end
5656
---Create a sanitized partial copy of a node
5757
---@return FileNode cloned
5858
function FileNode:clone()
59-
local clone = BaseNode.clone(self) --[[@as FileNode]]
59+
local clone = Node.clone(self) --[[@as FileNode]]
6060

6161
clone.extension = self.extension
6262

lua/nvim-tree/node/init.lua

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local Class = require("nvim-tree.class")
88

99
---Abstract Node class.
1010
---Uses the abstract factory pattern to instantiate child instances.
11-
---@class (exact) BaseNode: Class
11+
---@class (exact) Node: Class
1212
---@field type NODE_TYPE
1313
---@field explorer Explorer
1414
---@field absolute_path string
@@ -21,11 +21,9 @@ local Class = require("nvim-tree.class")
2121
---@field watcher Watcher?
2222
---@field diag_status DiagStatus?
2323
---@field is_dot boolean cached is_dotfile
24-
local BaseNode = Class:new()
24+
local Node = Class:new()
2525

26-
---@alias Node RootNode|BaseNode|DirectoryNode|FileNode|DirectoryLinkNode|FileLinkNode
27-
28-
function BaseNode:destroy()
26+
function Node:destroy()
2927
if self.watcher then
3028
self.watcher:destroy()
3129
self.watcher = nil
@@ -36,17 +34,17 @@ end
3634
---Update the GitStatus of the node
3735
---@param parent_ignored boolean
3836
---@param status table?
39-
function BaseNode:update_git_status(parent_ignored, status) ---@diagnostic disable-line: unused-local
37+
function Node:update_git_status(parent_ignored, status) ---@diagnostic disable-line: unused-local
4038
end
4139

4240
--luacheck: pop
4341

4442
---@return GitStatus?
45-
function BaseNode:get_git_status()
43+
function Node:get_git_status()
4644
end
4745

4846
---@param projects table
49-
function BaseNode:reload_node_status(projects)
47+
function Node:reload_node_status(projects)
5048
local toplevel = git.get_toplevel(self.absolute_path)
5149
local status = projects[toplevel] or {}
5250
for _, node in ipairs(self.nodes) do
@@ -58,13 +56,13 @@ function BaseNode:reload_node_status(projects)
5856
end
5957

6058
---@return boolean
61-
function BaseNode:is_git_ignored()
59+
function Node:is_git_ignored()
6260
return self.git_status ~= nil and self.git_status.file == "!!"
6361
end
6462

6563
---Node or one of its parents begins with a dot
6664
---@return boolean
67-
function BaseNode:is_dotfile()
65+
function Node:is_dotfile()
6866
if
6967
self.is_dot
7068
or (self.name and (self.name:sub(1, 1) == "."))
@@ -79,14 +77,14 @@ end
7977
---Return self, should only be called on a DirectoryNode
8078
---TODO #2886 remove method or leave in place, warn if practical and non too intrusive
8179
---@return Node
82-
function BaseNode:last_group_node()
83-
error(string.format("\nBaseNode:last_group_node called for '%s'", self.absolute_path))
80+
function Node:last_group_node()
81+
error(string.format("\nNode:last_group_node called for '%s'", self.absolute_path))
8482
return self
8583
end
8684

8785
---@param project table?
8886
---@param root string?
89-
function BaseNode:update_parent_statuses(project, root)
87+
function Node:update_parent_statuses(project, root)
9088
local node = self
9189
while project and node do
9290
-- step up to the containing project
@@ -118,7 +116,7 @@ end
118116

119117
---Get the highest parent of grouped nodes, nil when not grouped
120118
---@return DirectoryNode?
121-
function BaseNode:get_parent_of_group()
119+
function Node:get_parent_of_group()
122120
if not self.parent or not self.parent.group_next then
123121
return nil
124122
end
@@ -134,12 +132,12 @@ function BaseNode:get_parent_of_group()
134132
end
135133

136134
---Create a sanitized partial copy of a node, populating children recursively.
137-
---@return BaseNode cloned
138-
function BaseNode:clone()
135+
---@return Node cloned
136+
function Node:clone()
139137
---@type Explorer
140138
local explorer_placeholder = nil
141139

142-
---@type BaseNode
140+
---@type Node
143141
local clone = {
144142
type = self.type,
145143
explorer = explorer_placeholder,
@@ -158,4 +156,4 @@ function BaseNode:clone()
158156
return clone
159157
end
160158

161-
return BaseNode
159+
return Node

0 commit comments

Comments
 (0)