1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 08:52:39 +01:00

Render chevrons and carets in lint output for messages without "original" text

Summary:
If a message has only "line", or "line" and "char", we don't point out the location in the context block.

When a message includes "line", show chevrons on the line.
When a message includes "line" and "char", show chevrons on the line and a caret on the next line.

Test Plan: Ran regex linters to capture line, line+char, and normal linters to capture everything. Output appeared sane.

Reviewers: csilvers, vrana, btrahan

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2642
This commit is contained in:
epriestley 2012-06-01 15:53:16 -07:00
parent 0b45ec30be
commit c2788c8797
2 changed files with 22 additions and 2 deletions

View file

@ -204,13 +204,33 @@ final class ArcanistLintRenderer {
$end = min($num_lines, $cursor + $lines_of_context);
for (; $cursor < $end; $cursor++) {
$out[] = $this->renderLine($cursor, $line_data[$cursor]);
// If there is no original text, we didn't print out a chevron or any
// highlighted text above, so print it out here. This allows messages
// which don't have any original/replacement information to still
// render with indicator chevrons.
if ($text || $message->isPatchable()) {
$chevron = false;
} else {
$chevron = ($cursor == $line_num);
}
$out[] = $this->renderLine($cursor, $line_data[$cursor], $chevron);
// With original text, we'll render the text highlighted above. If the
// lint message only has a line/char offset there's nothing to
// highlight, so print out a caret on the next line instead.
if ($chevron && $message->getChar()) {
$out[] = $this->renderCaret($message->getChar());
}
}
$out[] = null;
return implode("\n", $out);
}
private function renderCaret($pos) {
return str_repeat(' ', 16 + $pos).'^';
}
protected function renderLine($line, $data, $chevron = false, $diff = null) {
$chevron = $chevron ? '>>>' : '';
return sprintf(

View file

@ -312,7 +312,7 @@ final class ArcanistScriptAndRegexLinter extends ArcanistLinter {
}
$line = idx($match, 'line', 1);
$char = idx($match, 'char', 1);
$char = idx($match, 'char');
return array($line, $char);
}