To implement a Debug Adapter (DAP) client, you must include the org.eclipse.lsp4j.debug dependency in your project.
Maven:
<dependency>
<groupId>org.eclipse.lsp4j</groupId>
<artifactId>org.eclipse.lsp4j.debug</artifactId>
<version><version></version>
</dependency>
Gradle:
compile group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j.debug', version: '<version>'
Use DSPLauncher.createClientLauncher to bootstrap the connection between your IDebugProtocolClient and the debug adapter process via its InputStream and OutputStream.
IDebugProtocolClient client = <...>;
Process process = <...>;
InputStream in = process.getInputStream();
OutputStream out = process.getOutputStream();
Launcher<IDebugProtocolServer> launcher = DSPLauncher.createClientLauncher(client, in, out);
launcher.startListening();
IDebugProtocolServer remoteProxy = launcher.getRemoteProxy();
// Example: Initialize
InitializeRequestArguments arguments = new InitializeRequestArguments();
arguments.setClientID("<client id>");
arguments.setAdapterID("<adapter id>");
Capabilities capabilities = remoteProxy.initialize(arguments).get(10, TimeUnit.SECONDS);
// Example: Launch
Map<String, Object> launchArgs = new HashMap<>();
launchArgs.put("terminal", "none");
launchArgs.put("target", "/path/to/target");
launchArgs.put("noDebug", false);
launchArgs.put("__sessionId", "sessionId");
remoteProxy.launch(launchArgs).get(10, TimeUnit.SECONDS);
// Example: Set Breakpoints
SetBreakpointsArguments breakpointArgs = new SetBreakpointsArguments();
Source source = new Source();
source.setName("target");
source.setPath("/path/to/target");
breakpointArgs.setSource(source);
SourceBreakpoint sourceBreakpoint = new SourceBreakpoint();
sourceBreakpoint.setLine(6);
SourceBreakpoint[] breakpoints = new SourceBreakpoint[]{sourceBreakpoint};
breakpointArgs.setBreakpoints(breakpoints);
remoteProxy.setBreakpoints(breakpointArgs).get(10, TimeUnit.SECONDS);
// Signal configuration is finished
remoteProxy.configurationDone(new ConfigurationDoneArguments());