fix: type annotations and type errors

This commit is contained in:
Steven Arcangeli 2023-08-12 20:32:52 -07:00
parent 0ccf95ae5d
commit 47c7737618
16 changed files with 83 additions and 22 deletions

View file

@ -184,8 +184,9 @@ M.enforce_action_order = function(actions)
-- a. TODO optimization: check immediate parents to see if they have no dependencies now
-- 5. repeat
-- Gets the dependencies of a particular action. Effectively dynamically calculates the dependency
-- "edges" of the graph.
---Gets the dependencies of a particular action. Effectively dynamically calculates the dependency
---"edges" of the graph.
---@param action oil.Action
local function get_deps(action)
local ret = {}
if action.type == "delete" then
@ -357,7 +358,9 @@ M.process_actions = function(actions, cb)
if v.type == "delete" then
local scheme, path = util.parse_url(v.url)
if config.adapters[scheme] == "files" then
actions[i] = {
assert(path)
---@type oil.MoveAction
local move_action = {
type = "move",
src_url = v.url,
entry_type = v.entry_type,
@ -366,6 +369,7 @@ M.process_actions = function(actions, cb)
math.random(999999)
),
}
actions[i] = move_action
end
end
end
@ -439,6 +443,7 @@ M.process_actions = function(actions, cb)
end
end)
if action.type == "change" then
---@cast action oil.ChangeAction
columns.perform_change_action(adapter, action, callback)
else
adapter.perform_action(action, callback)

View file

@ -76,6 +76,7 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
local adapter = util.get_adapter_for_action(action)
local line
if action.type == "change" then
---@cast action oil.ChangeAction
line = columns.render_change_action(adapter, action)
else
line = adapter.render_action(action)

View file

@ -169,6 +169,7 @@ function Progress:set_action(action, idx, total)
local adapter = util.get_adapter_for_action(action)
local change_line
if action.type == "change" then
---@cast action oil.ChangeAction
change_line = columns.render_change_action(adapter, action)
else
change_line = adapter.render_action(action)

View file

@ -1,6 +1,10 @@
local util = require("oil.util")
---@class oil.Trie
---@field private root table
local Trie = {}
---@return oil.Trie
Trie.new = function()
return setmetatable({
root = { values = {}, children = {} },
@ -13,6 +17,7 @@ end
---@return string[]
function Trie:_url_to_path_pieces(url)
local scheme, path = util.parse_url(url)
assert(path)
local pieces = vim.split(path, "/")
table.insert(pieces, 1, scheme)
return pieces
@ -131,7 +136,7 @@ end
---Add all actions at a specific path
---@param url string
---@param ret oil.InternalEntry[]
---@param filter nil|fun(entry: oil.InternalEntry): boolean
---@param filter? fun(entry: oil.InternalEntry): boolean
function Trie:accum_actions_at(url, ret, filter)
local pieces = self:_url_to_path_pieces(url)
local current = self.root