use of flash.tools.debugger.InProgressException in project intellij-plugins by JetBrains.
the class DebugCLI method doInfoFuncs.
void doInfoFuncs() {
StringBuilder sb = new StringBuilder();
String arg = null;
// we take an optional single arg which specifies a module
try {
// let's wait a bit for the background load to complete
waitForMetaData();
if (hasMoreTokens()) {
arg = nextToken();
//$NON-NLS-1$
int id = arg.equals(".") ? propertyGet(LIST_MODULE) : parseFileArg(-1, arg);
SourceFile m = m_fileInfo.getFile(id);
listFunctionsFor(sb, m);
} else {
SourceFile[] ar = m_fileInfo.getFileList();
if (ar == null)
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noSourceFilesFound"));
else {
for (int i = 0; ar != null && i < ar.length; i++) {
SourceFile m = ar[i];
listFunctionsFor(sb, m);
}
}
}
out(sb.toString());
} catch (NullPointerException npe) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noFunctionsFound"));
} catch (ParseException pe) {
err(pe.getMessage());
} catch (NoMatchException nme) {
err(nme.getMessage());
} catch (AmbiguousException ae) {
err(ae.getMessage());
} catch (InProgressException ipe) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("functionListBeingPrepared"));
}
}
use of flash.tools.debugger.InProgressException in project intellij-plugins by JetBrains.
the class DebugCLI method propagateBreakpoints.
/**
* Propagate current breakpoints to the newly loaded swf.
*/
void propagateBreakpoints() throws NotConnectedException {
// get the newly added swf, which lands at the end list
SwfInfo[] swfs = m_fileInfo.getSwfs();
SwfInfo swf = (swfs.length > 1) ? swfs[swfs.length - 1] : null;
// now walk through all breakpoints propagating the
// the break for each source and line number we
// find in the new swf
int size = m_breakpoints.size();
for (int i = 0; (swf != null) && i < size; i++) {
// dont do this for single swf breakpoints
BreakAction bp = breakpointAt(i);
if (bp.isSingleSwf())
continue;
if (bp.getStatus() != BreakAction.RESOLVED)
continue;
try {
Location l = bp.getLocation();
int line = l.getLine();
SourceFile f = l.getFile();
Location newLoc = findAndEnableBreak(swf, f, line);
if (newLoc != null)
bp.addLocation(newLoc);
} catch (InProgressException ipe) {
if (breakpointCount() > 0) {
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("breakpointNumber", Integer.toString(bp.getId()));
//$NON-NLS-1$
out(getLocalizationManager().getLocalizedTextString("breakpointNotPropagated", args));
}
}
}
}
use of flash.tools.debugger.InProgressException in project intellij-plugins by JetBrains.
the class DebugCLI method doInfoSwfs.
/**
* Dump some stats about our currently loaded swfs.
*/
void doInfoSwfs() {
try {
StringBuilder sb = new StringBuilder();
SwfInfo[] swfs = m_fileInfo.getSwfs();
for (int i = 0; i < swfs.length; i++) {
SwfInfo e = swfs[i];
if (e == null || e.isUnloaded())
continue;
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("swfName", FileInfoCache.nameOfSwf(e));
//$NON-NLS-1$
args.put("size", NumberFormat.getInstance().format(e.getSwfSize()));
try {
int size = e.getSwdSize(m_session);
// our swd is loaded so let's comb through our
// list of scripts and locate the range of ids.
SourceFile[] files = e.getSourceList(m_session);
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for (int j = 0; j < files.length; j++) {
SourceFile f = files[j];
int id = f.getId();
max = (id > max) ? id : max;
min = (id < min) ? id : min;
}
//$NON-NLS-1$
args.put("scriptCount", Integer.toString(e.getSourceCount(m_session)));
//$NON-NLS-1$
args.put("min", Integer.toString(min));
//$NON-NLS-1$
args.put("max", Integer.toString(max));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
args.put("plus", (e.isProcessingComplete()) ? "+" : "");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
args.put("moreInfo", (size == 0) ? getLocalizationManager().getLocalizedTextString("remainingSourceBeingLoaded") : "");
} catch (InProgressException ipe) {
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("debugInfoBeingLoaded"));
}
//$NON-NLS-1$
args.put("url", e.getUrl());
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("swfInfo", args));
sb.append(m_newline);
}
out(sb.toString());
} catch (NullPointerException npe) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noSWFs"));
}
}
use of flash.tools.debugger.InProgressException 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));
}
use of flash.tools.debugger.InProgressException in project intellij-plugins by JetBrains.
the class DebugCLI method parseFunctionName.
/**
* Parse a partial function name
* @param module the FIRST module to search; but we also search all the others if 'onlyThisModule' is false
* @return two ints: first is the module, and second is the line
*/
private int[] parseFunctionName(int module, String partialFunctionName, boolean onlyThisModule) throws NoMatchException, AmbiguousException {
// wait a bit before we try this to give the background thread time to complete
try {
waitForMetaData();
} catch (InProgressException ipe) {
}
SourceFile m = m_fileInfo.getFile(module);
// each member is a ModuleFunctionPair
ArrayList<ModuleFunctionPair> functionNames = new ArrayList<ModuleFunctionPair>();
appendFunctionNamesMatching(functionNames, m, partialFunctionName);
if (functionNames.size() == 0) {
if (!onlyThisModule) {
// not found in the specified module; search all the other modules
Iterator fileIter = m_fileInfo.getAllFiles();
while (fileIter.hasNext()) {
SourceFile nextFile = (SourceFile) ((Map.Entry) fileIter.next()).getValue();
if (// skip the one file we searched at the beginning
nextFile != m) {
appendFunctionNamesMatching(functionNames, nextFile, partialFunctionName);
}
}
}
if (functionNames.size() == 0) {
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("name", partialFunctionName);
//$NON-NLS-1$
throw new NoMatchException(getLocalizationManager().getLocalizedTextString("noFunctionWithSpecifiedName", args));
}
}
if (functionNames.size() > 1) {
ModuleFunctionPair[] functionNameArray = functionNames.toArray(new ModuleFunctionPair[functionNames.size()]);
Arrays.sort(functionNameArray);
//$NON-NLS-1$
String s = getLocalizationManager().getLocalizedTextString("ambiguousMatchingFunctionNames") + m_newline;
Map<String, Object> args = new HashMap<String, Object>();
for (int i = 0; i < functionNameArray.length; i++) {
String moduleName = m_fileInfo.getFile(functionNameArray[i].moduleId).getName();
String functionName = functionNameArray[i].functionName;
//$NON-NLS-1$
args.put("functionName", functionName);
//$NON-NLS-1$ //$NON-NLS-2$
args.put("filename", moduleName + "#" + functionNameArray[i].moduleId);
//$NON-NLS-1$ //$NON-NLS-2$
s += " " + getLocalizationManager().getLocalizedTextString("functionInFile", args);
if (i < functionNameArray.length - 1)
s += m_newline;
}
throw new AmbiguousException(s);
}
ModuleFunctionPair pair = functionNames.get(0);
module = pair.moduleId;
m = m_fileInfo.getFile(module);
int line = m.getLineForFunctionName(m_session, pair.functionName);
return new int[] { module, line };
}
Aggregations