mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Make lookupFileInformation() a private API on CelerityResourceMap
Summary: Ref T4222. Currently, this exposes a bunch of information about the Celerity internals. This information is difficult to preserve exactly with the new maps. Strengthen the API by providing more specific capabilities. Test Plan: Regenerated map, browsed around. Reviewers: btrahan, hach-que Reviewed By: hach-que CC: aran Maniphest Tasks: T4222 Differential Revision: https://secure.phabricator.com/D7867
This commit is contained in:
parent
543f635557
commit
8aaf5084e8
4 changed files with 48 additions and 17 deletions
|
@ -108,7 +108,7 @@ final class CelerityResourceMap {
|
|||
return idx($this->resourceMap, $symbol);
|
||||
}
|
||||
|
||||
public function lookupFileInformation($path) {
|
||||
private function lookupFileInformation($path) {
|
||||
if (empty($this->reverseMap)) {
|
||||
$this->reverseMap = array();
|
||||
foreach ($this->resourceMap as $symbol => $data) {
|
||||
|
@ -119,4 +119,36 @@ final class CelerityResourceMap {
|
|||
return idx($this->reverseMap, $path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the fully-qualified, absolute URI for the resource associated with
|
||||
* a resource name. This method is fairly low-level and ignores packaging.
|
||||
*
|
||||
* @param string Resource name to lookup.
|
||||
* @return string Fully-qualified resource URI.
|
||||
*/
|
||||
public function getFullyQualifiedURIForName($name) {
|
||||
$info = $this->lookupFileInformation($name);
|
||||
if ($info) {
|
||||
return idx($info, 'uri');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the resource symbols required by a named resource.
|
||||
*
|
||||
* @param string Resource name to lookup.
|
||||
* @return list<string> List of required symbols.
|
||||
*/
|
||||
public function getRequiredSymbolsForName($name) {
|
||||
$info = $this->lookupFileInformation($name);
|
||||
if ($info) {
|
||||
return idx($info, 'requires', array());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -127,9 +127,9 @@ final class CelerityResourceTransformer {
|
|||
$uri = $this->rawResourceMap[$uri]['uri'];
|
||||
}
|
||||
} else if ($this->celerityMap) {
|
||||
$info = $this->celerityMap->lookupFileInformation($uri);
|
||||
if ($info) {
|
||||
$uri = $info['uri'];
|
||||
$resource_uri = $this->celerityMap->getFullyQualifiedURIForName($uri);
|
||||
if ($resource_uri) {
|
||||
$uri = $resource_uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ function celerity_generate_unique_node_id() {
|
|||
function celerity_get_resource_uri($resource) {
|
||||
$map = CelerityResourceMap::getInstance();
|
||||
|
||||
$info = $map->lookupFileInformation($resource);
|
||||
if ($info) {
|
||||
return $info['uri'];
|
||||
} else {
|
||||
return $resource;
|
||||
$uri = $map->getFullyQualifiedURIForName($resource);
|
||||
if ($uri) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
return $resource;
|
||||
}
|
||||
|
|
|
@ -147,21 +147,20 @@ final class PhabricatorJavelinLinter extends ArcanistLinter {
|
|||
$path);
|
||||
$need = $external_classes;
|
||||
|
||||
$info = $celerity->lookupFileInformation(substr($path, strlen('webroot')));
|
||||
if (!$info) {
|
||||
$info = array();
|
||||
$resource_name = substr($path, strlen('webroot'));
|
||||
$requires = $celerity->getRequiredSymbolsForName($resource_name);
|
||||
if (!$requires) {
|
||||
$requires = array();
|
||||
}
|
||||
|
||||
$requires = idx($info, 'requires', array());
|
||||
|
||||
foreach ($requires as $key => $name) {
|
||||
$symbol_info = $celerity->lookupSymbolInformation($name);
|
||||
foreach ($requires as $key => $symbol_name) {
|
||||
$symbol_info = $celerity->lookupSymbolInformation($symbol_name);
|
||||
if (!$symbol_info) {
|
||||
$this->raiseLintAtLine(
|
||||
0,
|
||||
0,
|
||||
self::LINT_UNKNOWN_DEPENDENCY,
|
||||
"This file @requires component '{$name}', but it does not ".
|
||||
"This file @requires component '{$symbol_name}', but it does not ".
|
||||
"exist. You may need to rebuild the Celerity map.");
|
||||
unset($requires[$key]);
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue