Search in sources :

Example 1 with AddBreakpointWithScriptUriConsumer

use of org.dartlang.vm.service.consumer.AddBreakpointWithScriptUriConsumer in project flutter-intellij by flutter.

the class CanonicalBreakpoint method addBreakpoint.

public void addBreakpoint(@NotNull final String isolateId, @Nullable final XSourcePosition position, @NotNull final VmServiceConsumers.BreakpointsConsumer consumer) {
    if (position == null || position.getFile().getFileType() != DartFileType.INSTANCE) {
        consumer.sourcePositionNotApplicable();
        return;
    }
    addRequest(() -> {
        final int line = position.getLine() + 1;
        final Collection<String> scriptUris = myDebugProcess.getUrisForFile(position.getFile());
        final CanonicalBreakpoint canonicalBreakpoint = new CanonicalBreakpoint(position.getFile().getName(), position.getFile().getCanonicalPath(), line);
        canonicalBreakpoints.add(canonicalBreakpoint);
        final List<Breakpoint> breakpointResponses = new ArrayList<>();
        final List<RPCError> errorResponses = new ArrayList<>();
        for (String uri : scriptUris) {
            myVmService.addBreakpointWithScriptUri(isolateId, uri, line, new AddBreakpointWithScriptUriConsumer() {

                @Override
                public void received(Breakpoint response) {
                    breakpointResponses.add(response);
                    breakpointNumbersToCanonicalMap.put(response.getBreakpointNumber(), canonicalBreakpoint);
                    checkDone();
                }

                @Override
                public void received(Sentinel response) {
                    checkDone();
                }

                @Override
                public void onError(RPCError error) {
                    errorResponses.add(error);
                    checkDone();
                }

                private void checkDone() {
                    if (scriptUris.size() == breakpointResponses.size() + errorResponses.size()) {
                        consumer.received(breakpointResponses, errorResponses);
                    }
                }
            });
        }
    });
}
Also used : XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) Breakpoint(org.dartlang.vm.service.element.Breakpoint) AddBreakpointWithScriptUriConsumer(org.dartlang.vm.service.consumer.AddBreakpointWithScriptUriConsumer) Sentinel(org.dartlang.vm.service.element.Sentinel) ArrayList(java.util.ArrayList) RPCError(org.dartlang.vm.service.element.RPCError) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) Breakpoint(org.dartlang.vm.service.element.Breakpoint)

Aggregations

XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 ArrayList (java.util.ArrayList)1 AddBreakpointWithScriptUriConsumer (org.dartlang.vm.service.consumer.AddBreakpointWithScriptUriConsumer)1 Breakpoint (org.dartlang.vm.service.element.Breakpoint)1 RPCError (org.dartlang.vm.service.element.RPCError)1 Sentinel (org.dartlang.vm.service.element.Sentinel)1