mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +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);
|
return idx($this->resourceMap, $symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lookupFileInformation($path) {
|
private function lookupFileInformation($path) {
|
||||||
if (empty($this->reverseMap)) {
|
if (empty($this->reverseMap)) {
|
||||||
$this->reverseMap = array();
|
$this->reverseMap = array();
|
||||||
foreach ($this->resourceMap as $symbol => $data) {
|
foreach ($this->resourceMap as $symbol => $data) {
|
||||||
|
@ -119,4 +119,36 @@ final class CelerityResourceMap {
|
||||||
return idx($this->reverseMap, $path);
|
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'];
|
$uri = $this->rawResourceMap[$uri]['uri'];
|
||||||
}
|
}
|
||||||
} else if ($this->celerityMap) {
|
} else if ($this->celerityMap) {
|
||||||
$info = $this->celerityMap->lookupFileInformation($uri);
|
$resource_uri = $this->celerityMap->getFullyQualifiedURIForName($uri);
|
||||||
if ($info) {
|
if ($resource_uri) {
|
||||||
$uri = $info['uri'];
|
$uri = $resource_uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,10 @@ function celerity_generate_unique_node_id() {
|
||||||
function celerity_get_resource_uri($resource) {
|
function celerity_get_resource_uri($resource) {
|
||||||
$map = CelerityResourceMap::getInstance();
|
$map = CelerityResourceMap::getInstance();
|
||||||
|
|
||||||
$info = $map->lookupFileInformation($resource);
|
$uri = $map->getFullyQualifiedURIForName($resource);
|
||||||
if ($info) {
|
if ($uri) {
|
||||||
return $info['uri'];
|
return $uri;
|
||||||
} else {
|
|
||||||
return $resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $resource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,21 +147,20 @@ final class PhabricatorJavelinLinter extends ArcanistLinter {
|
||||||
$path);
|
$path);
|
||||||
$need = $external_classes;
|
$need = $external_classes;
|
||||||
|
|
||||||
$info = $celerity->lookupFileInformation(substr($path, strlen('webroot')));
|
$resource_name = substr($path, strlen('webroot'));
|
||||||
if (!$info) {
|
$requires = $celerity->getRequiredSymbolsForName($resource_name);
|
||||||
$info = array();
|
if (!$requires) {
|
||||||
|
$requires = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$requires = idx($info, 'requires', array());
|
foreach ($requires as $key => $symbol_name) {
|
||||||
|
$symbol_info = $celerity->lookupSymbolInformation($symbol_name);
|
||||||
foreach ($requires as $key => $name) {
|
|
||||||
$symbol_info = $celerity->lookupSymbolInformation($name);
|
|
||||||
if (!$symbol_info) {
|
if (!$symbol_info) {
|
||||||
$this->raiseLintAtLine(
|
$this->raiseLintAtLine(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
self::LINT_UNKNOWN_DEPENDENCY,
|
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.");
|
"exist. You may need to rebuild the Celerity map.");
|
||||||
unset($requires[$key]);
|
unset($requires[$key]);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue