Changeset View
Changeset View
Standalone View
Standalone View
src/lint/renderer/ArcanistConsoleLintRenderer.php
| Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | protected function renderContext( | ||||
| $line = $message->getLine(); | $line = $message->getLine(); | ||||
| $char = $message->getChar(); | $char = $message->getChar(); | ||||
| $old = $data; | $old = $data; | ||||
| $old_lines = phutil_split_lines($old); | $old_lines = phutil_split_lines($old); | ||||
| $old_impact = substr_count($original, "\n") + 1; | $old_impact = substr_count($original, "\n") + 1; | ||||
| $start = $line; | $start = $line; | ||||
| $max_old = count($old_lines); | |||||
| if ($start > $max_old) { | |||||
| // See PHI1782. If a linter raises a warning at a line that does not | |||||
| // exist, just render a warning. | |||||
| $line = $this->renderLine( | |||||
| $start, | |||||
| pht( | |||||
| '(This message was raised at line %s, but the file only has '. | |||||
| '%s line(s).)', | |||||
| new PhutilNumber($start), | |||||
| new PhutilNumber($max_old)), | |||||
| false, | |||||
| '?'); | |||||
| return $line."\n\n"; | |||||
| } | |||||
| if ($message->isPatchable()) { | if ($message->isPatchable()) { | ||||
| $patch_offset = $line_map[$line] + ($char - 1); | $patch_offset = $line_map[$line] + ($char - 1); | ||||
| $new = substr_replace( | $new = substr_replace( | ||||
| $old, | $old, | ||||
| $replacement, | $replacement, | ||||
| $patch_offset, | $patch_offset, | ||||
| strlen($original)); | strlen($original)); | ||||
| ▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines | |||||