Skip to content

Commit

Permalink
feat: add message when unsupported command is ran
Browse files Browse the repository at this point in the history
  • Loading branch information
s1n7ax committed Jul 11, 2024
1 parent f1ae757 commit 091bdb3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lua/java-refactor/refactor-commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ local class = require('java-core.utils.class')
local notify = require('java-core.utils.notify')
local JdtlsClient = require('java-core.ls.clients.jdtls-client')

local available_commands = {
-- 'assignField',
-- 'assignVariable',
-- 'changeSignature',
-- 'convertAnonymousClassToNestedCommand',
-- 'convertVariableToField',
'extractConstant',
'extractField',
-- 'extractInterface',
'extractMethod',
'extractVariable',
'extractVariableAllOccurrence',
-- 'introduceParameter',
-- 'invertVariable',
}

---@class java-refactor.RefactorCommands
---@field jdtls_client java-core.JdtlsClient
local RefactorCommands = class()
Expand All @@ -15,6 +31,13 @@ end
---@param refactor_type jdtls.CodeActionCommand
---@param context lsp.CodeActionContext
function RefactorCommands:refactor(refactor_type, context)
if not vim.tbl_contains(available_commands, refactor_type) then
notify.error(
string.format('Refactoring command "%s" is not supported', refactor_type)
)
return
end

if not context then
context = vim.lsp.util.make_range_params(0)
context.context = {}
Expand Down

0 comments on commit 091bdb3

Please sign in to comment.