use of org.eclipse.n4js.cli.helper.SystemExitRedirecter.SystemExitException in project n4js by eclipse.
the class InProcessExecuter method n4jsc.
/**
* Calls main entry point of N4jsc with the given args. Checks that the given exit code equals the actual exit code
* of the invocation. Removes {@link N4jscOptions#USAGE} text if desired.
*/
protected CliCompileResult n4jsc(Path workDir, String[] args, CliCompileResult cliResult) {
Stopwatch sw = Stopwatch.createStarted();
try {
setRedirections();
cliResult.workingDir = workDir.toString();
N4jscMain.main(workDir, args);
cliResult.exitCode = 0;
} catch (SystemExitException e) {
cliResult.exitCode = e.status;
} catch (Exception e) {
cliResult.exception = e;
if (cliResult.exitCode == ProcessResult.NO_EXIT_CODE) {
cliResult.exitCode = -1;
}
} finally {
cliResult.duration = sw.stop().elapsed(TimeUnit.MILLISECONDS);
cliResult.stdOut = systemOutRedirecter.getSystemOut();
cliResult.errOut = systemOutRedirecter.getSystemErr();
if (isEnabledBackend) {
N4jscTestLanguageClient callback = (N4jscTestLanguageClient) N4jscFactory.getLanguageClient();
cliResult.issues = callback.issues;
cliResult.errors = callback.errors;
cliResult.warnings = callback.warnings;
cliResult.transpiledFiles = callback.transpiledFiles;
cliResult.deletedFilesCount = callback.getDeletionsCount();
// save projects
Injector injector = N4jscFactory.getOrCreateInjector();
XWorkspaceManager workspaceManager = injector.getInstance(XWorkspaceManager.class);
Set<? extends ProjectConfigSnapshot> projects = workspaceManager.getProjectConfigs();
Map<String, String> projectMap = new TreeMap<>();
for (ProjectConfigSnapshot pConfig : projects) {
Path projectPath = URIUtils.toPath(pConfig.getPath());
Path relativeProjectPath = workDir.relativize(projectPath);
projectMap.put(pConfig.getName(), relativeProjectPath.toString());
}
cliResult.projects = projectMap;
}
unsetRedirections();
}
return cliResult;
}
Aggregations