Skip to content

Commit f32a722

Browse files
committed
chore: Use some of the new annotations.
Use `@enum` everywhere it applies. Use `@private`.
1 parent a6906ce commit f32a722

File tree

19 files changed

+88
-93
lines changed

19 files changed

+88
-93
lines changed

lua/diffview/diff.lua

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
local oop = require("diffview.oop")
66
local M = {}
77

8-
---@class EditToken
9-
---@field NOOP integer
10-
---@field DELETE integer
11-
---@field INSERT integer
12-
---@field REPLACE integer
13-
local EditToken = oop.enum({
14-
"NOOP",
15-
"DELETE",
16-
"INSERT",
17-
"REPLACE",
18-
})
8+
---@enum EditToken
9+
local EditToken = {
10+
NOOP = 1,
11+
DELETE = 2,
12+
INSERT = 3,
13+
REPLACE = 4,
14+
}
1915

2016
---@class Diff : diffview.Object
2117
---@field a any[]

lua/diffview/events.lua

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ local utils = lazy.require("diffview.utils")
66

77
local M = {}
88

9-
---@class Event
10-
11-
---@class EEvent
12-
---@field FILES_STAGED Event
13-
local Event = oop.enum({
14-
"FILES_STAGED",
15-
})
9+
---@enum Event
10+
local Event = {
11+
FILES_STAGED = 1,
12+
}
1613

1714
---@alias ListenerType '"normal"'|'"once"'|'"any"'|'"any_once"'
1815

lua/diffview/lib.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function M.diffview_open(args)
4646
return
4747
end
4848

49-
---@type DiffView
5049
local v = DiffView({
5150
adapter = adapter,
5251
rev_arg = rev_arg,
@@ -97,7 +96,6 @@ function M.file_history(range, args)
9796
return
9897
end
9998

100-
---@type FileHistoryView
10199
local v = FileHistoryView({
102100
adapter = adapter,
103101
log_options = log_options,

lua/diffview/path.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ function PathLib:init(o)
2323
self.cwd = o.cwd and self:convert(o.cwd) or nil
2424
end
2525

26+
---@private
2627
function PathLib:_cwd()
2728
return self.cwd or self:convert(uv.cwd())
2829
end
2930

31+
---@private
3032
---@return ...
3133
function PathLib:_clean(...)
3234
local argc = select("#", ...)

lua/diffview/scene/layouts/diff_3.lua

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@ local Window = require("diffview.scene.window").Window
33
local Layout = require("diffview.scene.layout").Layout
44
local oop = require("diffview.oop")
55

6-
---@type Diff1|LazyModule
7-
local Diff1 = lazy.access("diffview.scene.layouts.diff_1", "Diff1")
8-
---@type Diff4|LazyModule
9-
local Diff4 = lazy.access("diffview.scene.layouts.diff_4", "Diff4")
10-
---@type vcs.File|LazyModule
11-
local File = lazy.access("diffview.vcs.file", "File")
12-
---@type Rev|LazyModule
13-
local Rev = lazy.access("diffview.vcs.rev", "Rev")
14-
---@type ERevType|LazyModule
15-
local RevType = lazy.access("diffview.vcs.rev", "RevType")
6+
local Diff1 = lazy.access("diffview.scene.layouts.diff_1", "Diff1") ---@type Diff1|LazyModule
7+
local Diff4 = lazy.access("diffview.scene.layouts.diff_4", "Diff4") ---@type Diff4|LazyModule
8+
local File = lazy.access("diffview.vcs.file", "File") ---@type vcs.File|LazyModule
9+
local Rev = lazy.access("diffview.vcs.rev", "Rev") ---@type Rev|LazyModule
10+
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type RevType|LazyModule
1611

1712
local M = {}
1813

lua/diffview/scene/views/diff/diff_view.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ local PerfTimer = lazy.access("diffview.perf", "PerfTimer") ---@type PerfTimer|L
1212
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type RevType|LazyModule
1313
local StandardView = lazy.access("diffview.scene.views.standard.standard_view", "StandardView") ---@type StandardView|LazyModule
1414
local async = lazy.require("plenary.async") ---@module "plenary.async"
15+
local config = lazy.require("diffview.config") ---@module "diffview.config"
1516
local debounce = lazy.require("diffview.debounce") ---@module "diffview.debounce"
16-
local vcs = lazy.require("diffview.vcs.utils") ---@module "diffview.vcs.utils"
1717
local logger = lazy.require("diffview.logger") ---@module "diffview.logger"
1818
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"
19-
local config = lazy.require("diffview.config") ---@module "diffview.config"
19+
local vcs = lazy.require("diffview.vcs.utils") ---@module "diffview.vcs.utils"
2020

2121
local api = vim.api
2222
local M = {}
@@ -26,6 +26,7 @@ local M = {}
2626
---@field selected_file? string Path to the preferred initially selected file.
2727

2828
---@class DiffView : StandardView
29+
---@operator call:DiffView
2930
---@field adapter VCSAdapter
3031
---@field rev_arg string
3132
---@field path_args string[]
@@ -167,6 +168,7 @@ function DiffView:close()
167168
end
168169
end
169170

171+
---@private
170172
---@param file FileEntry
171173
function DiffView:_set_file(file)
172174
vim.cmd("redraw")

lua/diffview/scene/views/diff/listeners.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
local lazy = require("diffview.lazy")
22

3+
local Event = lazy.access("diffview.events", "Event") ---@type Event|LazyModule
4+
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type RevType|LazyModule
35
local actions = lazy.require("diffview.actions") ---@module "diffview.actions"
4-
local Event = lazy.access("diffview.events", "Event") ---@type EEvent
5-
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type ERevType
66
local async = lazy.require("plenary.async") ---@module "plenary.async"
7-
local vcs = lazy.require("diffview.vcs.utils") ---@module "diffview.vcs.utils"
87
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"
8+
local vcs = lazy.require("diffview.vcs.utils") ---@module "diffview.vcs.utils"
99

1010
local api = vim.api
1111

lua/diffview/scene/views/file_history/file_history_panel.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ function FileHistoryPanel:cur_file()
380380
return self.cur_item[2]
381381
end
382382

383+
---@private
384+
---@param entry_idx integer
385+
---@param file_idx integer
386+
---@param offset integer
387+
---@return LogEntry?
388+
---@return FileEntry?
383389
function FileHistoryPanel:_get_entry_by_file_offset(entry_idx, file_idx, offset)
384390
local cur_entry = self.entries[entry_idx]
385391

lua/diffview/scene/views/file_history/file_history_view.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ local CommitLogPanel = lazy.access("diffview.ui.panels.commit_log_panel", "Commi
55
local Event = lazy.access("diffview.events", "Event") ---@type Event|LazyModule
66
local FileEntry = lazy.access("diffview.scene.file_entry", "FileEntry") ---@type FileEntry|LazyModule
77
local FileHistoryPanel = lazy.access("diffview.scene.views.file_history.file_history_panel", "FileHistoryPanel") ---@type FileHistoryPanel|LazyModule
8+
local JobStatus = lazy.access("diffview.vcs.utils", "JobStatus") ---@type JobStatus|LazyModule
89
local StandardView = lazy.access("diffview.scene.views.standard.standard_view", "StandardView") ---@type StandardView|LazyModule
910
local config = lazy.require("diffview.config") ---@module "diffview.config"
1011

11-
local JobStatus = lazy.access("diffview.vcs.utils", "JobStatus") ---@type JobStatus|LazyModule
1212
local api = vim.api
1313

1414
local M = {}
1515

1616
---@class FileHistoryView : StandardView
17+
---@operator call:FileHistoryView
1718
---@field adapter VCSAdapter
1819
---@field panel FileHistoryPanel
1920
---@field commit_log_panel CommitLogPanel
@@ -79,6 +80,7 @@ function FileHistoryView:cur_file()
7980
return self.panel.cur_item[2]
8081
end
8182

83+
---@private
8284
---@param file FileEntry
8385
function FileHistoryView:_set_file(file)
8486
vim.cmd("redraw")

lua/diffview/scene/views/file_history/option_panel.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ function FHOptionPanel:init(parent)
154154
})
155155
end
156156

157+
---@private
157158
function FHOptionPanel:_set_option(name, value)
158159
self.parent.log_options.single_file[name] = value
159160
self.parent.log_options.multi_file[name] = value

0 commit comments

Comments
 (0)