File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 1- local async = require (' java-core.utils. async' ). sync
1+ local runner = require (' async.runner ' )
22local get_error_handler = require (' java.handlers.error' )
3+ local ui = require (' java.utils.ui' )
4+ local jdtls = require (' java.utils.jdtls2' )
35
46local M = {}
57
@@ -14,7 +16,7 @@ function M.full_build_workspace(is_full_build)
1416
1517 is_full_build = type (is_full_build ) == ' boolean' and is_full_build or true
1618
17- return async (function ()
19+ return runner (function ()
1820 JdtlsClient (jdtls ()):java_build_workspace (
1921 is_full_build ,
2022 buf_util .get_curr_buf ()
@@ -26,4 +28,25 @@ function M.full_build_workspace(is_full_build)
2628 .run ()
2729end
2830
31+ function M .clean_workspace ()
32+ runner (function ()
33+ local client = jdtls ()
34+
35+ local workpace_path =
36+ vim .tbl_get (client , ' config' , ' init_options' , ' workspace' )
37+
38+ local prompt = string.format (' Do you want to delete "%s"' , workpace_path )
39+
40+ local choice = ui .select (prompt , { ' Yes' , ' No' })
41+
42+ if choice ~= ' Yes' then
43+ return
44+ end
45+
46+ vim .fn .delete (workpace_path , ' rf' )
47+ end )
48+ .catch (get_error_handler (' Failed to clean up the workspace' ))
49+ .run ()
50+ end
51+
2952return M
Original file line number Diff line number Diff line change 11local log = require (' java.utils.log' )
22local notify = require (' java-core.utils.notify' )
3+ local ui = require (' java.utils.ui' )
4+ local get_error_handler = require (' java.handlers.error' )
5+ local runner = require (' async.runner' )
36
47local M = {}
58
@@ -125,6 +128,10 @@ M.handlers = {
125128 [M .commands .COMPILE_WORKSPACE ] = function (is_full_build )
126129 require (' java.api.build' ).full_build_workspace (is_full_build )
127130 end ,
131+
132+ [M .commands .CLEAN_WORKSPACE ] = function ()
133+ require (' java.api.build' ).clean_workspace ()
134+ end ,
128135}
129136
130137local ignored_commands = { M .commands .REFRESH_BUNDLES_COMMAND }
You can’t perform that action at this time.
0 commit comments