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

Restore the caret pointer ("^") for lint lines which only have a character offset

Summary: Ref T9846. This was dropped when I refactored how things are rendered; restore it.

Test Plan: Added unit tests.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9846

Differential Revision: https://secure.phabricator.com/D18511
This commit is contained in:
epriestley 2017-08-31 12:37:19 -07:00
parent 86779b1526
commit 213ed3ff15
4 changed files with 31 additions and 2 deletions

View file

@ -90,6 +90,7 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
$old = $data;
$old_lines = phutil_split_lines($old);
$start = $line;
if ($message->isPatchable()) {
$patch_offset = $line_map[$line] + ($char - 1);
@ -107,8 +108,6 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
$old_impact = substr_count($original, "\n") + 1;
$new_impact = substr_count($replacement, "\n") + 1;
$start = $line;
// If lines at the beginning of the changed line range are actually the
// same, shrink the range. This happens when a patch just adds a line.
do {
@ -214,6 +213,14 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
$spec['text'],
$chevron,
idx($spec, 'type'));
// If this is just a message and does not have a patch, put a little
// caret underneath the line to point out where the issue is.
if ($chevron) {
if (!$message->isPatchable() && !strlen($original)) {
$result[] = $this->renderCaret($char)."\n";
}
}
}
return implode('', $result);

View file

@ -54,6 +54,13 @@ final class ArcanistConsoleLintRendererTestCase
'original' => '',
'replacement' => "\n",
),
'caret' => array(
'line' => 2,
'char' => 13,
'name' => 'Fruit Misinformation',
'description' => 'Arguably untrue.',
),
);
$defaults = array(

View file

@ -0,0 +1,11 @@
>>> Lint for path/to/example.c:
Warning (WARN123) Fruit Misinformation
Arguably untrue.
1 Apples are round.
>>> 2 Bananas are round.
^
3 Cherries are round.
4 Dates are round.

View file

@ -0,0 +1,4 @@
Apples are round.
Bananas are round.
Cherries are round.
Dates are round.