Skip to content

Commit

Permalink
Show nicer error if classpath resolve fails when debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Feb 9, 2024
1 parent 4f4de4d commit 894c044
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lua/jdtls/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ local function enrich_dap_config(config_, on_config)
assert(not err, err and (err.message or vim.inspect(err)))

if not config.projectName then
for _, entry in ipairs(mainclasses) do
if entry.mainClass == config.mainClass then
config.projectName = entry.projectName
break
if not mainclasses then
local msg = "Could not resolve classpaths. Project may have compile errors or unresolved dependencies"
vim.notify(msg, vim.log.levels.WARN)
else
for _, entry in ipairs(mainclasses) do
if entry.mainClass == config.mainClass then
config.projectName = entry.projectName
break
end
end
end
end
Expand All @@ -62,13 +67,17 @@ local function enrich_dap_config(config_, on_config)
}
util.execute_command(params, function(err1, paths)
assert(not err1, err1 and (err1.message or vim.inspect(err1)))
config.modulePaths = config.modulePaths or paths[1]
config.classPaths = config.classPaths or vim.tbl_filter(
function(x)
return vim.fn.isdirectory(x) == 1 or vim.fn.filereadable(x) == 1
end,
paths[2]
)
if paths then
config.modulePaths = config.modulePaths or paths[1]
config.classPaths = config.classPaths or vim.tbl_filter(
function(x)
return vim.fn.isdirectory(x) == 1 or vim.fn.filereadable(x) == 1
end,
paths[2]
)
else
vim.notify("Could not resolve classpaths. Project may have compile errors or unresolved dependencies", vim.log.levels.WARN)
end
on_config(config)
end, bufnr)
end, bufnr)
Expand Down

0 comments on commit 894c044

Please sign in to comment.