Changeset View
Changeset View
Standalone View
Standalone View
src/lint/ArcanistLintPatcher.php
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (Filesystem::pathExists($path)) { | ||||
| // This path may not exist if we're generating a new file. | // This path may not exist if we're generating a new file. | ||||
| execx('cp -p %s %s', $path, $lint); | execx('cp -p %s %s', $path, $lint); | ||||
| } | } | ||||
| Filesystem::writeFile($lint, $data); | Filesystem::writeFile($lint, $data); | ||||
| list($err) = exec_manual('mv -f %s %s', $lint, $path); | list($err) = exec_manual('mv -f %s %s', $lint, $path); | ||||
| if ($err) { | if ($err) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Unable to overwrite path `{$path}', patched version was left ". | pht( | ||||
| "at `{$lint}'."); | "Unable to overwrite path '%s', patched version was left at '%s'.", | ||||
| $path, | |||||
| $lint)); | |||||
| } | } | ||||
| foreach ($this->applyMessages as $message) { | foreach ($this->applyMessages as $message) { | ||||
| $message->didApplyPatch(); | $message->didApplyPatch(); | ||||
| } | } | ||||
| } | } | ||||
| private function __construct() {} | private function __construct() {} | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if ($this->lineOffsets === null) { | ||||
| $last = 0; | $last = 0; | ||||
| foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
| $this->lineOffsets[] = $last + strlen($line) + 1; | $this->lineOffsets[] = $last + strlen($line) + 1; | ||||
| $last += strlen($line) + 1; | $last += strlen($line) + 1; | ||||
| } | } | ||||
| } | } | ||||
| if ($line_num >= count($this->lineOffsets)) { | if ($line_num >= count($this->lineOffsets)) { | ||||
| throw new Exception("Data has fewer than `{$line}' lines."); | throw new Exception(pht('Data has fewer than %d lines.', $line)); | ||||
| } | } | ||||
| return idx($this->lineOffsets, $line_num); | return idx($this->lineOffsets, $line_num); | ||||
| } | } | ||||
| private function setDirtyCharacterOffset($offset) { | private function setDirtyCharacterOffset($offset) { | ||||
| $this->dirtyUntil = $offset; | $this->dirtyUntil = $offset; | ||||
| return $this; | return $this; | ||||
| Show All 16 Lines | |||||