Skip to content

Commit 894c044

Browse files
committed
Show nicer error if classpath resolve fails when debugging
1 parent 4f4de4d commit 894c044

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

lua/jdtls/dap.lua

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ local function enrich_dap_config(config_, on_config)
4646
assert(not err, err and (err.message or vim.inspect(err)))
4747

4848
if not config.projectName then
49-
for _, entry in ipairs(mainclasses) do
50-
if entry.mainClass == config.mainClass then
51-
config.projectName = entry.projectName
52-
break
49+
if not mainclasses then
50+
local msg = "Could not resolve classpaths. Project may have compile errors or unresolved dependencies"
51+
vim.notify(msg, vim.log.levels.WARN)
52+
else
53+
for _, entry in ipairs(mainclasses) do
54+
if entry.mainClass == config.mainClass then
55+
config.projectName = entry.projectName
56+
break
57+
end
5358
end
5459
end
5560
end
@@ -62,13 +67,17 @@ local function enrich_dap_config(config_, on_config)
6267
}
6368
util.execute_command(params, function(err1, paths)
6469
assert(not err1, err1 and (err1.message or vim.inspect(err1)))
65-
config.modulePaths = config.modulePaths or paths[1]
66-
config.classPaths = config.classPaths or vim.tbl_filter(
67-
function(x)
68-
return vim.fn.isdirectory(x) == 1 or vim.fn.filereadable(x) == 1
69-
end,
70-
paths[2]
71-
)
70+
if paths then
71+
config.modulePaths = config.modulePaths or paths[1]
72+
config.classPaths = config.classPaths or vim.tbl_filter(
73+
function(x)
74+
return vim.fn.isdirectory(x) == 1 or vim.fn.filereadable(x) == 1
75+
end,
76+
paths[2]
77+
)
78+
else
79+
vim.notify("Could not resolve classpaths. Project may have compile errors or unresolved dependencies", vim.log.levels.WARN)
80+
end
7281
on_config(config)
7382
end, bufnr)
7483
end, bufnr)

0 commit comments

Comments
 (0)