mirror of
https://github.com/mfussenegger/nvim-jdtls
synced 2024-09-16 14:34:13 +02:00
Add context param to dap test methods
Allows to set the buffer/window for which to trigger a test
This commit is contained in:
parent
efefcdc108
commit
efacec1c97
3 changed files with 27 additions and 8 deletions
4
.luarc.json
Normal file
4
.luarc.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||||
|
"Lua.workspace.checkThirdParty": false
|
||||||
|
}
|
|
@ -183,6 +183,14 @@ JdtSetupDapOpts *JdtSetupDapOpts*
|
||||||
{hotcodereplace?} (string) "auto"
|
{hotcodereplace?} (string) "auto"
|
||||||
|
|
||||||
|
|
||||||
|
JdtDapContext *JdtDapContext*
|
||||||
|
|
||||||
|
Fields: ~
|
||||||
|
{bufnr} (number)
|
||||||
|
{win} (number)
|
||||||
|
{uri} (string) uri equal to vim.uri_from_bufnr(bufnr)
|
||||||
|
|
||||||
|
|
||||||
JdtDapConfig *JdtDapConfig*
|
JdtDapConfig *JdtDapConfig*
|
||||||
|
|
||||||
Fields: ~
|
Fields: ~
|
||||||
|
@ -194,10 +202,11 @@ JdtDapConfig *JdtDapConfig*
|
||||||
JdtTestOpts *JdtTestOpts*
|
JdtTestOpts *JdtTestOpts*
|
||||||
|
|
||||||
Fields: ~
|
Fields: ~
|
||||||
{config} (nil|table) Skeleton used for the |dap-configuration|
|
{config} (nil|table) Skeleton used for the |dap-configuration|
|
||||||
{config_overrides} (nil|JdtDapConfig) Overrides for the |dap-configuration|, see |JdtDapConfig|
|
{config_overrides} (nil|JdtDapConfig) Overrides for the |dap-configuration|, see |JdtDapConfig|
|
||||||
{until_error} (number|nil) Number of times the test should be repeated if it doesn't fail
|
{until_error} (number|nil) Number of times the test should be repeated if it doesn't fail
|
||||||
{after_test} (nil|function) Callback triggered after test run
|
{after_test} (nil|function) Callback triggered after test run
|
||||||
|
{context} (JdtDapContext|nil) context with bufnr/win in which the test is triggered
|
||||||
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
|
|
@ -323,6 +323,7 @@ local function make_config(lens, launch_args, config_overrides)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return JdtDapContext
|
||||||
local function make_context()
|
local function make_context()
|
||||||
local bufnr = api.nvim_get_current_buf()
|
local bufnr = api.nvim_get_current_buf()
|
||||||
return {
|
return {
|
||||||
|
@ -413,7 +414,7 @@ M.experimental = {
|
||||||
--- @param opts JdtTestOpts|nil
|
--- @param opts JdtTestOpts|nil
|
||||||
function M.test_class(opts)
|
function M.test_class(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local context = make_context()
|
local context = opts.context or make_context()
|
||||||
fetch_candidates(context, function(lenses)
|
fetch_candidates(context, function(lenses)
|
||||||
local lens = get_first_class_lens(lenses)
|
local lens = get_first_class_lens(lenses)
|
||||||
if not lens then
|
if not lens then
|
||||||
|
@ -432,8 +433,8 @@ end
|
||||||
--- @param opts nil|JdtTestOpts
|
--- @param opts nil|JdtTestOpts
|
||||||
function M.test_nearest_method(opts)
|
function M.test_nearest_method(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local lnum = api.nvim_win_get_cursor(0)[1]
|
local context = opts.context or make_context()
|
||||||
local context = make_context()
|
local lnum = api.nvim_win_get_cursor(context.win)[1]
|
||||||
fetch_candidates(context, function(lenses)
|
fetch_candidates(context, function(lenses)
|
||||||
local lens = get_method_lens_above_cursor(lenses, lnum)
|
local lens = get_method_lens_above_cursor(lenses, lnum)
|
||||||
if not lens then
|
if not lens then
|
||||||
|
@ -452,7 +453,7 @@ end
|
||||||
---@param opts nil|JdtTestOpts
|
---@param opts nil|JdtTestOpts
|
||||||
function M.pick_test(opts)
|
function M.pick_test(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local context = make_context()
|
local context = opts.context or make_context()
|
||||||
fetch_candidates(context, function(lenses)
|
fetch_candidates(context, function(lenses)
|
||||||
require('jdtls.ui').pick_one_async(
|
require('jdtls.ui').pick_one_async(
|
||||||
lenses,
|
lenses,
|
||||||
|
@ -611,6 +612,10 @@ end
|
||||||
---@field config_overrides JdtDapConfig These will be used as default overrides for |jdtls.dap.test_class|, |jdtls.dap.test_nearest_method| and discovered main classes
|
---@field config_overrides JdtDapConfig These will be used as default overrides for |jdtls.dap.test_class|, |jdtls.dap.test_nearest_method| and discovered main classes
|
||||||
---@field hotcodereplace? string "auto"
|
---@field hotcodereplace? string "auto"
|
||||||
|
|
||||||
|
---@class JdtDapContext
|
||||||
|
---@field bufnr number
|
||||||
|
---@field win number
|
||||||
|
---@field uri string uri equal to vim.uri_from_bufnr(bufnr)
|
||||||
|
|
||||||
---@class JdtDapConfig
|
---@class JdtDapConfig
|
||||||
---@field cwd string|nil working directory for the test
|
---@field cwd string|nil working directory for the test
|
||||||
|
@ -622,5 +627,6 @@ end
|
||||||
---@field config_overrides nil|JdtDapConfig Overrides for the |dap-configuration|, see |JdtDapConfig|
|
---@field config_overrides nil|JdtDapConfig Overrides for the |dap-configuration|, see |JdtDapConfig|
|
||||||
---@field until_error number|nil Number of times the test should be repeated if it doesn't fail
|
---@field until_error number|nil Number of times the test should be repeated if it doesn't fail
|
||||||
---@field after_test nil|function Callback triggered after test run
|
---@field after_test nil|function Callback triggered after test run
|
||||||
|
---@field context JdtDapContext|nil context with bufnr/win in which the test is triggered
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in a new issue