Skip to content

Commit 64cd9b5

Browse files
committed
Add a update_projects_config function
Exposes eclipse-jdtls/eclipse.jdt.ls#2131
1 parent 3a148da commit 64cd9b5

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

doc/jdtls.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ M.update_project_config() *jdtls.update_project_config*
2626
module of the current buffer.
2727

2828

29+
M.update_projects_config({mode}) *jdtls.update_projects_config*
30+
Process changes made to the Gradle or Maven configuration of one or more projects.
31+
Requires eclipse.jdt.ls >= 1.13.0
32+
33+
34+
35+
Parameters: ~
36+
{mode} (nil|"prompt"|"all") Whether to prompt for projects to update or update all. Defaults to "prompt"
37+
38+
2939
M.javap() *jdtls.javap*
3040
Run the `javap` tool in a terminal buffer.
3141
Sets the classpath based on the current project.

lua/jdtls.lua

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,43 @@ function M.update_project_config()
699699
end)
700700
end
701701

702+
--- Process changes made to the Gradle or Maven configuration of one or more projects.
703+
--- Requires eclipse.jdt.ls >= 1.13.0
704+
---
705+
---@param mode nil|"prompt"|"all" Whether to prompt for projects to update or update all. Defaults to "prompt"
706+
function M.update_projects_config(mode)
707+
mode = mode or "pick"
708+
local bufnr = api.nvim_get_current_buf()
709+
local command = {
710+
command = 'java.project.getAll',
711+
}
712+
util.execute_command(command, function(err, projects)
713+
if err then
714+
error(err.message or vim.inspect(err))
715+
end
716+
local selection
717+
if mode == "all" then
718+
selection = projects
719+
elseif #projects == 1 then
720+
selection = projects
721+
else
722+
selection = ui.pick_many(
723+
projects,
724+
'Projects> ',
725+
function(project)
726+
return vim.fn.fnamemodify(project, ':.:t')
727+
end
728+
)
729+
end
730+
if selection and next(selection) then
731+
local params = {
732+
identifiers = vim.tbl_map(function(project) return { uri = project } end, selection)
733+
}
734+
vim.lsp.buf_notify(bufnr, 'java/projectConfigurationsUpdate', params)
735+
end
736+
end, bufnr)
737+
end
738+
702739

703740
local function mk_extract(entity)
704741
return function(from_selection)

0 commit comments

Comments
 (0)