Search in sources :

Example 1 with FunctionBreakpoint

use of org.eclipse.lsp4j.debug.FunctionBreakpoint 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)

Example 2 with FunctionBreakpoint

use of org.eclipse.lsp4j.debug.FunctionBreakpoint in project magik-tools by StevenLooman.

the class BreakpointManager method addFunctionBreakpoints.

/**
 * Add multiple function breakpoints.
 *
 * @param functionBreakpoints Breakpoints to be set.
 * @return List of {{MagikBreakpoint}}s.
 * @throws ExecutionException -
 * @throws InterruptedException -
 * @throws IOException -
 */
List<MagikBreakpoint> addFunctionBreakpoints(final FunctionBreakpoint[] functionBreakpoints) throws IOException, InterruptedException, ExecutionException {
    final List<MagikBreakpoint> breakpoints = new ArrayList<>();
    for (final FunctionBreakpoint functionBreakpoint : functionBreakpoints) {
        final MagikBreakpoint magikBreakpoint = this.addFunctionBreakpoint(functionBreakpoint);
        breakpoints.add(magikBreakpoint);
    }
    return breakpoints;
}
Also used : ArrayList(java.util.ArrayList) FunctionBreakpoint(org.eclipse.lsp4j.debug.FunctionBreakpoint)

Example 3 with FunctionBreakpoint

use of org.eclipse.lsp4j.debug.FunctionBreakpoint in project magik-tools by StevenLooman.

the class BreakpointManager method addFunctionBreakpoint.

/**
 * Add a function breakpoint.
 *
 * @param functionBreakpoint {{FunctionBreakpoint}} to add.
 * @return Created {{MagikBreakpoint}}.
 * @throws IOException -
 * @throws ExecutionException -
 * @throws InterruptedException -
 */
MagikBreakpoint addFunctionBreakpoint(final FunctionBreakpoint functionBreakpoint) throws IOException, InterruptedException, ExecutionException {
    final Source source = null;
    final String methodName = functionBreakpoint.getName();
    final int methodLine = 0;
    final String condition = functionBreakpoint.getCondition();
    return this.createBreakpoint(source, methodName, methodLine, condition);
}
Also used : Source(org.eclipse.lsp4j.debug.Source) FunctionBreakpoint(org.eclipse.lsp4j.debug.FunctionBreakpoint) SourceBreakpoint(org.eclipse.lsp4j.debug.SourceBreakpoint)

Aggregations

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