Search in sources :

Example 1 with SetBreakpointsResponseBody

use of com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody in project vscode-nextgenas by BowlerHatLLC.

the class SWFDebugSession method setBreakpoints.

public void setBreakpoints(Response response, SetBreakpointsRequest.SetBreakpointsArguments arguments) {
    String path = arguments.source.path;
    Path pathAsPath = Paths.get(path);
    List<Breakpoint> breakpoints = new ArrayList<>();
    for (int i = 0, count = arguments.breakpoints.length; i < count; i++) {
        SourceBreakpoint sourceBreakpoint = arguments.breakpoints[i];
        int sourceLine = sourceBreakpoint.line;
        Breakpoint responseBreakpoint = new Breakpoint();
        responseBreakpoint.line = sourceLine;
        int fileId = -1;
        try {
            SwfInfo[] swfs = swfSession.getSwfs();
            for (SwfInfo swf : swfs) {
                SourceFile[] sourceFiles = swf.getSourceList(swfSession);
                for (SourceFile sourceFile : sourceFiles) {
                    //file system case sensitivity.
                    if (pathAsPath.equals(Paths.get(sourceFile.getFullPath())) && (path.endsWith(FILE_EXTENSION_AS) || path.endsWith(FILE_EXTENSION_MXML))) {
                        fileId = sourceFile.getId();
                        break;
                    }
                }
                if (fileId != -1) {
                    break;
                }
            }
            if (fileId == -1) {
                //either the file was not found, or it has an unsupported
                //extension
                responseBreakpoint.verified = false;
            } else {
                Location breakpointLocation = swfSession.setBreakpoint(fileId, sourceLine);
                if (breakpointLocation != null) {
                    //I don't know if the line could change, but might as well
                    //use the one returned by the location
                    responseBreakpoint.line = breakpointLocation.getLine();
                    responseBreakpoint.verified = true;
                } else {
                    //setBreakpoint() may return null if the breakpoint could
                    //not be set. that's fine. the user will see that the
                    //breakpoint is not verified, so it's fine.
                    responseBreakpoint.verified = false;
                }
            }
        } catch (InProgressException e) {
            e.printStackTrace(System.err);
            responseBreakpoint.verified = false;
        } catch (NoResponseException e) {
            e.printStackTrace(System.err);
            responseBreakpoint.verified = false;
        } catch (NotConnectedException e) {
            e.printStackTrace(System.err);
            responseBreakpoint.verified = false;
        }
        breakpoints.add(responseBreakpoint);
    }
    sendResponse(response, new SetBreakpointsResponseBody(breakpoints));
}
Also used : Path(java.nio.file.Path) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) InProgressException(flash.tools.debugger.InProgressException) NotConnectedException(flash.tools.debugger.NotConnectedException) SwfInfo(flash.tools.debugger.SwfInfo) ArrayList(java.util.ArrayList) SetBreakpointsResponseBody(com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) SourceFile(flash.tools.debugger.SourceFile) NoResponseException(flash.tools.debugger.NoResponseException) Location(flash.tools.debugger.Location)

Aggregations

SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)1 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)1 SetBreakpointsResponseBody (com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody)1 InProgressException (flash.tools.debugger.InProgressException)1 Location (flash.tools.debugger.Location)1 NoResponseException (flash.tools.debugger.NoResponseException)1 NotConnectedException (flash.tools.debugger.NotConnectedException)1 SourceFile (flash.tools.debugger.SourceFile)1 SwfInfo (flash.tools.debugger.SwfInfo)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1