1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Improve syntax error output from "arc liberate"

Summary:
Currently, when a file has a syntax error and you run "arc liberate", the symbol analyzer will fail and throw, which will make the mapper fail and throw, which will make arc fail and throw. This gives you a stack trace pile three scripts deep which is a giant pain to analyze visually.

Instead, raise a clear message.

Test Plan: Ran "arc liberate" with a syntax error. Got useful diagnostic output instead of 30 pages of stack mess.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2659
This commit is contained in:
epriestley 2012-06-06 10:53:02 -07:00
parent 52f8f49aef
commit 6f6fde84cc
2 changed files with 25 additions and 2 deletions

View file

@ -230,8 +230,18 @@ final class PhutilLibraryMapBuilder {
$this->log("Analyzing {$count} files with {$limit} subprocesses...\n");
foreach (Futures($futures)->limit($limit) as $file => $future) {
$result = $future->resolveJSON();
if (empty($result['error'])) {
$symbol_map[$file] = $result;
} else {
echo phutil_console_format(
"\n**SYNTAX ERROR!**\nFile: %s\nLine: %d\n\n%s\n",
Filesystem::readablePath($result['file']),
$result['line'],
$result['error']);
exit(1);
}
$this->log(".");
$symbol_map[$file] = $future->resolveJSON();
}
$this->log("\nDone.\n");
}

View file

@ -75,7 +75,20 @@ $path = Filesystem::resolvePath(head($paths));
$show_all = $args->getArg('all');
$source_code = Filesystem::readFile($path);
$tree = XHPASTTree::newFromData($source_code);
try {
$tree = XHPASTTree::newFromData($source_code);
} catch (XHPASTSyntaxErrorException $ex) {
$result = array(
'error' => $ex->getMessage(),
'line' => $ex->getErrorLine(),
'file' => $path,
);
$json = new PhutilJSON();
echo $json->encodeFormatted($result);
exit(0);
}
$root = $tree->getRootNode();
$root->buildSelectCache();