Skip to content

Commit

Permalink
chore: code rename
Browse files Browse the repository at this point in the history
  • Loading branch information
s1n7ax committed Jul 24, 2024
1 parent 77a6079 commit 98db44a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lua/java-refactor/action.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local ui = require('java.utils.ui')
local class = require('java-core.utils.class')
local JdtlsClient = require('java-core.ls.clients.jdtls-client')
local RefactorCommands = require('java-refactor.refactor-commands')
local RefactorCommands = require('java-refactor.refactor')
local notify = require('java-core.utils.notify')
local List = require('java-core.utils.list')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ local available_actions = List:new({
-- 'extractInterface',
}):concat(refactor_edit_request_needed_actions)

---@class java-refactor.RefactorCommands
---@class java-refactor.Refactor
---@field jdtls_client java-core.JdtlsClient
local RefactorCommands = class()
local Refactor = class()

---@param client vim.lsp.Client
function RefactorCommands:_init(client)
function Refactor:_init(client)
self.jdtls_client = JdtlsClient(client)
end

---Run refactor command
---@param action_name jdtls.CodeActionCommand
---@param action_context lsp.CodeActionParams
---@param action_info lsp.LSPAny
function RefactorCommands:refactor(action_name, action_context, action_info)
function Refactor:refactor(action_name, action_context, action_info)
if not vim.tbl_contains(available_actions, action_name) then
notify.error(
string.format('Refactoring command "%s" is not supported', action_name)
Expand All @@ -49,7 +49,7 @@ function RefactorCommands:refactor(action_name, action_context, action_info)
end

if vim.tbl_contains(refactor_edit_request_needed_actions, action_name) then
local formatting_options = RefactorCommands.make_formatting_options()
local formatting_options = Refactor.make_formatting_options()
local selections

if vim.tbl_contains(refactor_edit_request_needed_actions, action_name) then
Expand All @@ -64,7 +64,7 @@ function RefactorCommands:refactor(action_name, action_context, action_info)
vim.api.nvim_get_current_buf()
)

RefactorCommands.perform_refactor_edit(changes)
Refactor.perform_refactor_edit(changes)
elseif action_name == 'moveFile' then
self:move_file(action_info --[[@as jdtls.CodeActionMoveTypeCommandInfo]])
elseif action_name == 'moveType' then
Expand All @@ -87,7 +87,7 @@ end

---@private
---@param action_info jdtls.CodeActionMoveTypeCommandInfo
function RefactorCommands:move_file(action_info)
function Refactor:move_file(action_info)
if not action_info or not action_info.uri then
return
end
Expand Down Expand Up @@ -133,13 +133,13 @@ function RefactorCommands:move_file(action_info)
destination = selected_destination,
})

RefactorCommands.perform_refactor_edit(changes)
Refactor.perform_refactor_edit(changes)
end

---@private
---@param action_context lsp.CodeActionParams
---@param action_info jdtls.CodeActionMoveTypeCommandInfo
function RefactorCommands:move_instance_method(action_context, action_info)
function Refactor:move_instance_method(action_context, action_info)
local move_des = self.jdtls_client:get_move_destination({
moveKind = 'moveInstanceMethod',
sourceUris = { action_context.textDocument.uri },
Expand Down Expand Up @@ -189,7 +189,7 @@ end
---@private
---@param action_context lsp.CodeActionParams
---@param action_info jdtls.CodeActionMoveTypeCommandInfo
function RefactorCommands:move_static_member(action_context, action_info)
function Refactor:move_static_member(action_context, action_info)
local exclude = List:new()

if action_info.enclosingTypeName then
Expand Down Expand Up @@ -227,7 +227,7 @@ end
---@private
---@param action_context lsp.CodeActionParams
---@param action_info jdtls.CodeActionMoveTypeCommandInfo
function RefactorCommands:move_type(action_context, action_info)
function Refactor:move_type(action_context, action_info)
if not action_info or not action_info.supportedDestinationKinds then
return
end
Expand Down Expand Up @@ -287,20 +287,20 @@ end
---@param move_kind string
---@param action_context lsp.CodeActionParams
---@param destination? jdtls.InstanceMethodMoveDestination | jdtls.ResourceMoveDestination | lsp.SymbolInformation
function RefactorCommands:perform_move(move_kind, action_context, destination)
function Refactor:perform_move(move_kind, action_context, destination)
local changes = self.jdtls_client:java_move({
moveKind = move_kind,
sourceUris = { action_context.textDocument.uri },
params = action_context,
destination = destination,
})

RefactorCommands.perform_refactor_edit(changes)
Refactor.perform_refactor_edit(changes)
end

---@private
---@param changes jdtls.RefactorWorkspaceEdit
function RefactorCommands.perform_refactor_edit(changes)
function Refactor.perform_refactor_edit(changes)
if not changes then
notify.warn('No edits suggested for the code action')
return
Expand All @@ -313,7 +313,7 @@ function RefactorCommands.perform_refactor_edit(changes)
vim.lsp.util.apply_workspace_edit(changes.edit, 'utf-8')

if changes.command then
RefactorCommands.run_lsp_client_command(
Refactor.run_lsp_client_command(
changes.command.command,
changes.command.arguments
)
Expand All @@ -324,7 +324,7 @@ end
---@param prompt string
---@param project_name string
---@param exclude string[]
function RefactorCommands:select_target_class(prompt, project_name, exclude)
function Refactor:select_target_class(prompt, project_name, exclude)
local classes = self.jdtls_client:java_search_symbols({
query = '*',
projectName = project_name,
Expand All @@ -347,7 +347,7 @@ end
---@private
---@param command_name string
---@param arguments any
function RefactorCommands.run_lsp_client_command(command_name, arguments)
function Refactor.run_lsp_client_command(command_name, arguments)
local command = vim.lsp.commands[command_name]

if not command then
Expand All @@ -360,7 +360,7 @@ end

---@private
---@return lsp.FormattingOptions
function RefactorCommands.make_formatting_options()
function Refactor.make_formatting_options()
return {
tabSize = vim.bo.tabstop,
insertSpaces = vim.bo.expandtab,
Expand All @@ -371,7 +371,7 @@ end
---@param refactor_type jdtls.CodeActionCommand
---@param params lsp.CodeActionParams
---@return jdtls.SelectionInfo[]
function RefactorCommands:get_selections(refactor_type, params)
function Refactor:get_selections(refactor_type, params)
local selections = List:new()
local buffer = vim.api.nvim_get_current_buf()

Expand Down Expand Up @@ -413,4 +413,4 @@ end
---@field supportedDestinationKinds string[]
---@field uri? string

return RefactorCommands
return Refactor

0 comments on commit 98db44a

Please sign in to comment.