Search in sources :

Example 1 with MagikBreakpoint

use of nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint in project magik-tools by StevenLooman.

the class MagikDebugAdapter method setBreakpoints.

@Override
public CompletableFuture<SetBreakpointsResponse> setBreakpoints(final SetBreakpointsArguments args) {
    LOGGER.trace("setBreakpoints");
    return CompletableFuture.supplyAsync(() -> {
        final Source source = args.getSource();
        // Do some manual fixing if needed.
        if (source.getName() == null && source.getPath() != null) {
            final Path path = Path.of(source.getPath());
            final String name = path.getFileName().toString();
            source.setName(name);
        }
        try {
            final SourceBreakpoint[] sourceBreakpoints = args.getBreakpoints();
            final List<MagikBreakpoint> magikBreakpoints = this.breakpointManager.setBreakpoints(source, sourceBreakpoints);
            // Return response.
            final SetBreakpointsResponse response = new SetBreakpointsResponse();
            final Breakpoint[] breakpoints = Lsp4jConversion.toLsp4j(source, magikBreakpoints);
            response.setBreakpoints(breakpoints);
            return response;
        } catch (InterruptedException exception) {
            java.lang.Thread.currentThread().interrupt();
            throw new CompletionException(exception.getMessage(), exception);
        } catch (IOException | ExecutionException exception) {
            throw new CompletionException(exception.getMessage(), exception);
        }
    });
}
Also used : Path(java.nio.file.Path) MagikBreakpoint(nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint) Breakpoint(org.eclipse.lsp4j.debug.Breakpoint) FunctionBreakpoint(org.eclipse.lsp4j.debug.FunctionBreakpoint) SourceBreakpoint(org.eclipse.lsp4j.debug.SourceBreakpoint) MagikBreakpoint(nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint) IOException(java.io.IOException) Source(org.eclipse.lsp4j.debug.Source) SourceBreakpoint(org.eclipse.lsp4j.debug.SourceBreakpoint) CompletionException(java.util.concurrent.CompletionException) ExecutionException(java.util.concurrent.ExecutionException) SetBreakpointsResponse(org.eclipse.lsp4j.debug.SetBreakpointsResponse)

Example 2 with MagikBreakpoint

use of nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint in project magik-tools by StevenLooman.

the class MagikDebugAdapter method setFunctionBreakpoints.

@Override
public CompletableFuture<SetFunctionBreakpointsResponse> setFunctionBreakpoints(final SetFunctionBreakpointsArguments args) {
    LOGGER.trace("setFunctionBreakpoints");
    return CompletableFuture.supplyAsync(() -> {
        try {
            // Clear existing breakpoints.
            this.breakpointManager.clearFunctionBreakpoints();
            // Set new breakpoints.
            final FunctionBreakpoint[] functionBreakpoints = args.getBreakpoints();
            final List<MagikBreakpoint> magikBreakpoints = this.breakpointManager.addFunctionBreakpoints(functionBreakpoints);
            // Return response.
            final SetFunctionBreakpointsResponse response = new SetFunctionBreakpointsResponse();
            final Breakpoint[] breakpoints = Lsp4jConversion.toLsp4j(null, magikBreakpoints);
            response.setBreakpoints(breakpoints);
            return response;
        } catch (InterruptedException exception) {
            java.lang.Thread.currentThread().interrupt();
            throw new CompletionException(exception.getMessage(), exception);
        } catch (IOException | ExecutionException exception) {
            throw new CompletionException(exception.getMessage(), exception);
        }
    });
}
Also used : MagikBreakpoint(nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint) Breakpoint(org.eclipse.lsp4j.debug.Breakpoint) FunctionBreakpoint(org.eclipse.lsp4j.debug.FunctionBreakpoint) SourceBreakpoint(org.eclipse.lsp4j.debug.SourceBreakpoint) MagikBreakpoint(nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint) CompletionException(java.util.concurrent.CompletionException) SetFunctionBreakpointsResponse(org.eclipse.lsp4j.debug.SetFunctionBreakpointsResponse) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) FunctionBreakpoint(org.eclipse.lsp4j.debug.FunctionBreakpoint)

Aggregations

IOException (java.io.IOException)2 CompletionException (java.util.concurrent.CompletionException)2 ExecutionException (java.util.concurrent.ExecutionException)2 MagikBreakpoint (nl.ramsolutions.sw.magik.debugadapter.BreakpointManager.MagikBreakpoint)2 Breakpoint (org.eclipse.lsp4j.debug.Breakpoint)2 FunctionBreakpoint (org.eclipse.lsp4j.debug.FunctionBreakpoint)2 SourceBreakpoint (org.eclipse.lsp4j.debug.SourceBreakpoint)2 Path (java.nio.file.Path)1 SetBreakpointsResponse (org.eclipse.lsp4j.debug.SetBreakpointsResponse)1 SetFunctionBreakpointsResponse (org.eclipse.lsp4j.debug.SetFunctionBreakpointsResponse)1 Source (org.eclipse.lsp4j.debug.Source)1