Changeset View
Changeset View
Standalone View
Standalone View
src/ref/simple/ArcanistSimpleSymbolHardpointQuery.php
- This file was moved from src/ref/file/ArcanistFileSymbolHardpointQuery.php.
<?php | <?php | ||||
final class ArcanistFileSymbolHardpointQuery | final class ArcanistSimpleSymbolHardpointQuery | ||||
extends ArcanistRuntimeHardpointQuery { | extends ArcanistRuntimeHardpointQuery { | ||||
public function getHardpoints() { | public function getHardpoints() { | ||||
return array( | return array( | ||||
ArcanistFileSymbolRef::HARDPOINT_OBJECT, | ArcanistFileSymbolRef::HARDPOINT_OBJECT, | ||||
); | ); | ||||
} | } | ||||
protected function canLoadRef(ArcanistRef $ref) { | protected function canLoadRef(ArcanistRef $ref) { | ||||
return ($ref instanceof ArcanistFileSymbolRef); | return ($ref instanceof ArcanistSimpleSymbolRef); | ||||
} | } | ||||
public function loadHardpoint(array $refs, $hardpoint) { | public function loadHardpoint(array $refs, $hardpoint) { | ||||
$id_map = array(); | $id_map = array(); | ||||
$phid_map = array(); | $phid_map = array(); | ||||
foreach ($refs as $key => $ref) { | foreach ($refs as $key => $ref) { | ||||
switch ($ref->getSymbolType()) { | switch ($ref->getSymbolType()) { | ||||
case ArcanistFileSymbolRef::TYPE_ID: | case ArcanistSimpleSymbolRef::TYPE_ID: | ||||
$id_map[$key] = $ref->getSymbol(); | $id_map[$key] = $ref->getSymbol(); | ||||
break; | break; | ||||
case ArcanistFileSymbolRef::TYPE_PHID: | case ArcanistSimpleSymbolRef::TYPE_PHID: | ||||
$phid_map[$key] = $ref->getSymbol(); | $phid_map[$key] = $ref->getSymbol(); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
$template_ref = head($refs); | |||||
$conduit_method = | |||||
$template_ref->getSimpleSymbolConduitSearchMethodName(); | |||||
$conduit_attachments = | |||||
$template_ref->getSimpleSymbolConduitSearchAttachments(); | |||||
$futures = array(); | $futures = array(); | ||||
if ($id_map) { | if ($id_map) { | ||||
$id_future = $this->newConduitSearch( | $id_future = $this->newConduitSearch( | ||||
'file.search', | $conduit_method, | ||||
array( | array( | ||||
'ids' => array_values(array_fuse($id_map)), | 'ids' => array_values(array_fuse($id_map)), | ||||
)); | ), | ||||
$conduit_attachments); | |||||
$futures[] = $id_future; | $futures[] = $id_future; | ||||
} else { | } else { | ||||
$id_future = null; | $id_future = null; | ||||
} | } | ||||
if ($phid_map) { | if ($phid_map) { | ||||
$phid_future = $this->newConduitSearch( | $phid_future = $this->newConduitSearch( | ||||
'file.search', | $ref->getSimpleSymbolConduitSearchMethodName(), | ||||
array( | array( | ||||
'phids' => array_values(array_fuse($phid_map)), | 'phids' => array_values(array_fuse($phid_map)), | ||||
)); | ), | ||||
$conduit_attachments); | |||||
$futures[] = $phid_future; | $futures[] = $phid_future; | ||||
} else { | } else { | ||||
$phid_future = null; | $phid_future = null; | ||||
} | } | ||||
yield $this->yieldFutures($futures); | yield $this->yieldFutures($futures); | ||||
Show All 12 Lines | if ($phid_future) { | ||||
$phid_results = $phid_future->resolve(); | $phid_results = $phid_future->resolve(); | ||||
$phid_results = ipull($phid_results, null, 'phid'); | $phid_results = ipull($phid_results, null, 'phid'); | ||||
foreach ($phid_map as $key => $phid) { | foreach ($phid_map as $key => $phid) { | ||||
$result_map[$key] = idx($phid_results, $phid); | $result_map[$key] = idx($phid_results, $phid); | ||||
} | } | ||||
} | } | ||||
$object_ref = $template_ref->newSimpleSymbolObjectRef(); | |||||
foreach ($result_map as $key => $raw_result) { | foreach ($result_map as $key => $raw_result) { | ||||
if ($raw_result === null) { | if ($raw_result === null) { | ||||
continue; | continue; | ||||
} | } | ||||
$result_map[$key] = ArcanistFileRef::newFromConduit($raw_result); | $result_map[$key] = call_user_func_array( | ||||
array(get_class($object_ref), 'newFromConduit'), | |||||
array($raw_result)); | |||||
} | } | ||||
yield $this->yieldMap($result_map); | yield $this->yieldMap($result_map); | ||||
} | } | ||||
} | } |