use of com.nextgenactionscript.vscode.debug.events.OutputEvent in project vscode-nextgenas by BowlerHatLLC.
the class SWFDebugSession method launch.
public void launch(Response response, LaunchRequest.LaunchRequestArguments args) {
LaunchRequestArguments swfArgs = (LaunchRequestArguments) args;
ThreadSafeSessionManager manager = ThreadSafeBootstrap.sessionManager();
swfSession = null;
try {
manager.startListening();
if (manager.supportsLaunch()) {
String program = swfArgs.program;
Path programPath = Paths.get(program);
if (!programPath.isAbsolute()) {
//if it's not an absolute path, we'll treat it as a
//relative path within the workspace
String workspacePath = System.getProperty(WORKSPACE_PROPERTY);
if (workspacePath != null) {
program = Paths.get(workspacePath).resolve(programPath).toAbsolutePath().toString();
}
}
Player player = null;
CustomRuntimeLauncher launcher = null;
if (swfArgs.runtimeExecutable != null) {
//if runtimeExecutable is specified, we'll launch that
launcher = new CustomRuntimeLauncher(swfArgs.runtimeExecutable, swfArgs.runtimeArgs);
} else {
//otherwise, let the SWF debugger automatically figure out
//which runtime is required based on the program path
String playerPath = program;
try {
URI uri = Paths.get(playerPath).toUri();
playerPath = uri.toString();
} catch (Exception e) {
//safe to ignore
}
player = manager.playerForUri(playerPath, null);
if (player == null && !playerPath.startsWith("http:") && !playerPath.startsWith("https:") && playerPath.endsWith(".swf")) {
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
launcher = findWindowsStandalonePlayer();
} else if (//linux
!System.getProperty("os.name").toLowerCase().startsWith("mac os")) {
launcher = findLinuxStandalonePlayer();
}
}
}
if (player == null && launcher == null) {
sendErrorResponse(response, 10001, "Error launching SWF debug session. Runtime not found for program: " + program);
return;
} else {
AIRLaunchInfo launchInfo = null;
//check if the debugger automatically detected AIR
boolean isAIR = player != null && player.getType() == Player.AIR;
if (!isAIR && player == null && program.endsWith(FILE_EXTENSION_XML)) {
//otherwise, check if the program to launch is an AIR
//application descriptor
isAIR = true;
}
if (isAIR && adlPath != null) {
launchInfo = new AIRLaunchInfo();
launchInfo.profile = swfArgs.profile;
launchInfo.screenSize = swfArgs.screensize;
launchInfo.dpi = swfArgs.screenDPI;
launchInfo.versionPlatform = swfArgs.versionPlatform;
launchInfo.airDebugLauncher = adlPath.toFile();
launchInfo.extDir = swfArgs.extdir;
if (launcher != null) {
launcher.isAIR = true;
}
}
if (launcher != null) {
swfSession = (ThreadSafeSession) manager.launch(program, launchInfo, true, null, null, launcher);
} else {
swfSession = (ThreadSafeSession) manager.launch(program, launchInfo, true, null, null);
}
}
}
} catch (CommandLineException e) {
OutputEvent.OutputBody body = new OutputEvent.OutputBody();
body.output = e.getMessage() + "\n" + e.getCommandOutput();
body.category = OutputEvent.CATEGORY_STDERR;
sendEvent(new OutputEvent(body));
e.printStackTrace(System.err);
sendErrorResponse(response, 10001, "Error launching SWF debug session. Process exited with code: " + e.getExitValue());
return;
} catch (IOException e) {
e.printStackTrace(System.err);
sendErrorResponse(response, 10001, "Error launching SWF debug session.");
return;
}
try {
swfSession.bind();
} catch (VersionException e) {
e.printStackTrace(System.err);
}
try {
manager.stopListening();
} catch (IOException e) {
e.printStackTrace(System.err);
}
sendResponse(response);
cancelRunner = false;
sessionThread = new java.lang.Thread(new SessionRunner());
sessionThread.start();
}
Aggregations