Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | public function lintPath($path) { | ||||
$celerity = CelerityResourceMap::getNamedInstance('phabricator'); | $celerity = CelerityResourceMap::getNamedInstance('phabricator'); | ||||
$path = preg_replace( | $path = preg_replace( | ||||
'@^externals/javelinjs/src/@', | '@^externals/javelinjs/src/@', | ||||
'webroot/rsrc/js/javelin/', | 'webroot/rsrc/js/javelin/', | ||||
$path); | $path); | ||||
$need = $external_classes; | $need = $external_classes; | ||||
$resource_name = substr($path, strlen('webroot')); | $resource_name = substr($path, strlen('webroot/')); | ||||
$requires = $celerity->getRequiredSymbolsForName($resource_name); | $requires = $celerity->getRequiredSymbolsForName($resource_name); | ||||
if (!$requires) { | if (!$requires) { | ||||
$requires = array(); | $requires = array(); | ||||
} | } | ||||
foreach ($requires as $key => $requires_symbol) { | foreach ($requires as $key => $requires_symbol) { | ||||
$requires_name = $celerity->getResourceNameForSymbol($requires_symbol); | $requires_name = $celerity->getResourceNameForSymbol($requires_symbol); | ||||
if ($requires_name === null) { | if ($requires_name === null) { | ||||
$this->raiseLintAtLine( | $this->raiseLintAtLine( | ||||
0, | 0, | ||||
0, | 0, | ||||
self::LINT_UNKNOWN_DEPENDENCY, | self::LINT_UNKNOWN_DEPENDENCY, | ||||
"This file @requires component '{$requires_symbol}', but it does ". | "This file @requires component '{$requires_symbol}', but it does ". | ||||
"not exist. You may need to rebuild the Celerity map."); | "not exist. You may need to rebuild the Celerity map."); | ||||
unset($requires[$key]); | unset($requires[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
if (preg_match('/\\.css$/', $requires_name)) { | if (preg_match('/\\.css$/', $requires_name)) { | ||||
// If JS requires CSS, just assume everything is fine. | // If JS requires CSS, just assume everything is fine. | ||||
unset($requires[$key]); | unset($requires[$key]); | ||||
} else { | } else { | ||||
$symbol_path = 'webroot'.$requires_name; | $symbol_path = 'webroot/'.$requires_name; | ||||
list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath( | list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath( | ||||
$symbol_path); | $symbol_path); | ||||
if (array_intersect_key($req_install, $external_classes)) { | if (array_intersect_key($req_install, $external_classes)) { | ||||
$need = array_diff_key($need, $req_install); | $need = array_diff_key($need, $req_install); | ||||
unset($requires[$key]); | unset($requires[$key]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |