Changeset View
Changeset View
Standalone View
Standalone View
src/ref/file/ArcanistFileSymbolRef.php
| <?php | <?php | ||||
| final class ArcanistFileSymbolRef | final class ArcanistFileSymbolRef | ||||
| extends ArcanistSymbolRef { | extends ArcanistSimpleSymbolRef { | ||||
| private $type; | |||||
| const TYPE_ID = 'id'; | |||||
| const TYPE_PHID = 'phid'; | |||||
| public function getRefDisplayName() { | public function getRefDisplayName() { | ||||
| return pht('File Symbol "%s"', $this->getSymbol()); | return pht('File Symbol "%s"', $this->getSymbol()); | ||||
| } | } | ||||
| protected function newCacheKeyParts() { | protected function getSimpleSymbolPrefixPattern() { | ||||
| return array( | return '[Ff]?'; | ||||
| sprintf('type(%s)', $this->type), | |||||
| ); | |||||
| } | } | ||||
| public function getSymbolType() { | protected function getSimpleSymbolPHIDType() { | ||||
| return $this->type; | return 'FILE'; | ||||
| } | } | ||||
| protected function resolveSymbol($symbol) { | public function getSimpleSymbolConduitSearchMethodName() { | ||||
| $matches = null; | return 'file.search'; | ||||
| $is_id = preg_match('/^[Ff]?([1-9]\d*)\z/', $symbol, $matches); | |||||
| if ($is_id) { | |||||
| $this->type = self::TYPE_ID; | |||||
| return (int)$matches[1]; | |||||
| } | } | ||||
| $is_phid = preg_match('/^PHID-FILE-\S+\z/', $symbol, $matches); | public function getSimpleSymbolInspectFunctionName() { | ||||
| if ($is_phid) { | return 'file'; | ||||
| $this->type = self::TYPE_PHID; | |||||
| return $matches[0]; | |||||
| } | } | ||||
| throw new PhutilArgumentUsageException( | public function newSimpleSymbolObjectRef() { | ||||
| pht( | return new ArcanistFileRef(); | ||||
| 'The format of file symbol "%s" is unrecognized. Expected a '. | |||||
| 'monogram like "F123", or an ID like "123", or a file PHID.', | |||||
| $symbol)); | |||||
| } | } | ||||
| } | } | ||||