Search in sources :

Example 6 with NoResponseException

use of flash.tools.debugger.NoResponseException 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)

Example 7 with NoResponseException

use of flash.tools.debugger.NoResponseException in project intellij-plugins by JetBrains.

the class DebugCLI method breakDisableRequest.

/**
	 * Notification that a breakpoint has been removed (or disabled)
	 * at the CLI level and we may need to remove it at the session level
	 */
void breakDisableRequest(LocationCollection col) throws NotConnectedException {
    // now let's comb the table looking to see if this breakpoint should
    // be removed at the session level.  Use the first entry as a template
    // for which location we are talking about.
    int at = 0;
    boolean hit = false;
    Location l = col.first();
    do {
        at = breakpointIndexOf(l, at);
        if (at > -1) {
            if (breakpointAt(at).isEnabled())
                hit = true;
            else
                // our location match is not enabled but let's continue after the hit
                at++;
        }
    } while (at > -1 && !hit);
    // no one matches, so let's remove it at the session level
    if (!hit) {
        Iterator<Location> itr = col.iterator();
        while (itr.hasNext()) {
            l = itr.next();
            try {
                m_session.clearBreakpoint(l);
            } catch (NoResponseException nre) {
            }
        }
    }
}
Also used : NoResponseException(flash.tools.debugger.NoResponseException) Location(flash.tools.debugger.Location)

Example 8 with NoResponseException

use of flash.tools.debugger.NoResponseException in project intellij-plugins by JetBrains.

the class DebugCLI method isMetaDataAvailable.

/**
	 * Ask each swf if metadata processing is complete
	 */
public boolean isMetaDataAvailable() {
    boolean allLoaded = true;
    try {
        // we need to ask the session since our fileinfocache will hide the exception
        SwfInfo[] swfs = m_session.getSwfs();
        for (int i = 0; i < swfs.length; i++) {
            // check if our processing is finished.
            SwfInfo swf = swfs[i];
            if (swf != null && !swf.isProcessingComplete()) {
                allLoaded = false;
                break;
            }
        }
    } catch (NoResponseException nre) {
        // ok we still need to wait for player to read the swd in
        allLoaded = false;
    }
    // count the number of times we checked and it wasn't there
    if (!allLoaded) {
        int count = propertyGet(METADATA_NOT_AVAILABLE);
        count++;
        propertyPut(METADATA_NOT_AVAILABLE, count);
    } else {
        // success so we reset our attempt counter
        propertyPut(METADATA_ATTEMPTS, METADATA_RETRIES);
    }
    return allLoaded;
}
Also used : SwfInfo(flash.tools.debugger.SwfInfo) DSwfInfo(flash.tools.debugger.concrete.DSwfInfo) NoResponseException(flash.tools.debugger.NoResponseException)

Aggregations

NoResponseException (flash.tools.debugger.NoResponseException)8 NotConnectedException (flash.tools.debugger.NotConnectedException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 InProgressException (flash.tools.debugger.InProgressException)2 Location (flash.tools.debugger.Location)2 NotSuspendedException (flash.tools.debugger.NotSuspendedException)2 PlayerDebugException (flash.tools.debugger.PlayerDebugException)2 SwfInfo (flash.tools.debugger.SwfInfo)2 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)1 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)1 SetBreakpointsResponseBody (com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody)1 Session (flash.tools.debugger.Session)1 SourceFile (flash.tools.debugger.SourceFile)1 SuspendedException (flash.tools.debugger.SuspendedException)1 Value (flash.tools.debugger.Value)1 Variable (flash.tools.debugger.Variable)1 VersionException (flash.tools.debugger.VersionException)1 DSwfInfo (flash.tools.debugger.concrete.DSwfInfo)1 DValue (flash.tools.debugger.concrete.DValue)1