Skip to content

Commit cff4448

Browse files
authored
refactor: changes after dap apis transfer from java core to java dap (nvim-java#39)
* refactor: changes related to dap API transfer from java-core to java-dap * chore: remove unwanted test config * fix(test): add missing dep to java-dap for testing
1 parent 1fb58a6 commit cff4448

4 files changed

Lines changed: 40 additions & 41 deletions

File tree

lua/java/dap/init.lua

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ local win_util = require('java.utils.window')
55
local async = require('java-core.utils.async').sync
66
local notify = require('java-core.utils.notify')
77

8-
local JavaCoreDap = require('java-core.dap')
8+
local DapSetup = require('java-dap.api.setup')
9+
local DapRunner = require('java-dap.api.runner')
10+
911
local JavaCoreTestApi = require('java-core.api.test')
1012
local JavaCoreTestClient = require('java-core.ls.clients.java-test-client')
11-
local JavaCoreDapRunner = require('java-core.dap.runner')
1213

1314
---@class JavaDap
1415
---@field private client LspClient
1516
---@field private dap JavaCoreDap
1617
---@field private test_api java_core.TestApi
17-
---@field private test_client java_core.TestClient
18+
---@field private test_client java-core.TestClient
1819
local M = {}
1920

2021
---@param args { client: LspClient }
@@ -26,16 +27,10 @@ function M:new(args)
2627

2728
o.test_api = JavaCoreTestApi:new({
2829
client = args.client,
29-
runner = JavaCoreDapRunner:new(),
30-
})
31-
32-
o.test_client = JavaCoreTestClient:new({
33-
client = args.client,
30+
runner = DapRunner(),
3431
})
3532

36-
o.dap = JavaCoreDap:new({
37-
client = args.client,
38-
})
33+
o.dap = DapSetup(args.client)
3934

4035
setmetatable(o, self)
4136
self.__index = self

tests/minimal_init.lua

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/prepare-config.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
22

3+
---@diagnostic disable: assign-type-mismatch
4+
---@param path string
5+
---@return string|nil
6+
local function local_plug(path)
7+
return vim.fn.isdirectory(path) == 1 and path or nil
8+
end
9+
310
if not vim.loop.fs_stat(lazypath) then
411
vim.fn.system({
512
'git',
@@ -14,8 +21,6 @@ end
1421
vim.opt.rtp:prepend(lazypath)
1522

1623
local temp_path = './.test_plugins'
17-
local java_core_path = vim.fn.expand('~/Workspace/nvim-java-core')
18-
local java_test_path = vim.fn.expand('~/Workspace/nvim-java-test')
1924

2025
require('lazy').setup({
2126
{
@@ -25,13 +30,19 @@ require('lazy').setup({
2530
{
2631
'nvim-java/nvim-java-test',
2732
---@diagnostic disable-next-line: assign-type-mismatch
28-
dir = vim.fn.isdirectory(java_test_path) == 1 and java_test_path or nil,
33+
dir = local_plug('~/Workspace/nvim-java-test'),
2934
lazy = false,
3035
},
3136
{
3237
'nvim-java/nvim-java-core',
3338
---@diagnostic disable-next-line: assign-type-mismatch
34-
dir = vim.fn.isdirectory(java_core_path) == 1 and java_core_path or nil,
39+
dir = local_plug('~/Workspace/nvim-java-core'),
40+
lazy = false,
41+
},
42+
{
43+
'nvim-java/nvim-java-dap',
44+
---@diagnostic disable-next-line: assign-type-mismatch
45+
dir = local_plug('~/Workspace/nvim-java-dap'),
3546
lazy = false,
3647
},
3748
{

tests/test-config.lua

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
local java_core_path = vim.fn.expand('~/Workspace/nvim-java-core')
2-
local java_test_path = vim.fn.expand('~/Workspace/nvim-java-test')
1+
---@diagnostic disable: assign-type-mismatch
2+
---@param dev_path string
3+
---@param plug_path string
4+
---@return string|nil
5+
local function local_plug(dev_path, plug_path)
6+
return (vim.fn.isdirectory(dev_path) == 1) and dev_path or plug_path
7+
end
38

49
local plug_path = './.test_plugins'
510

6-
java_core_path = (vim.fn.isdirectory(java_core_path) == 1) and java_core_path
7-
or (plug_path .. '/nvim-java-core')
8-
9-
java_test_path = (vim.fn.isdirectory(java_test_path) == 1) and java_test_path
10-
or (plug_path .. '/nvim-java-test')
11-
1211
vim.opt.rtp:append(plug_path .. '/plenary.nvim')
1312
vim.opt.rtp:append(plug_path .. '/nvim-lspconfig')
1413
vim.opt.rtp:append(plug_path .. '/mason.nvim')
15-
vim.opt.rtp:append(java_core_path)
16-
vim.opt.rtp:append(java_test_path)
14+
15+
vim.opt.rtp:append(
16+
local_plug('~/Workspace/nvim-java-core', plug_path .. '/nvim-java-core')
17+
)
18+
19+
vim.opt.rtp:append(
20+
local_plug('~/Workspace/nvim-java-test', plug_path .. '/nvim-java-test')
21+
)
22+
23+
vim.opt.rtp:append(
24+
local_plug('~/Workspace/nvim-java-dap', plug_path .. '/nvim-java-dap')
25+
)

0 commit comments

Comments
 (0)