mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Use PhutilClassMapQuery instead of PhutilSymbolLoader
Summary: Use `PhutilClassMapQuery` instead of `PhutilSymbolLoader`, mainly for consistency. Depends on D13572. Test Plan: This hasn't been tested very comphrehensively as of yet. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13573
This commit is contained in:
parent
587f7440e3
commit
0e09578720
4 changed files with 10 additions and 56 deletions
|
@ -35,28 +35,10 @@ class ArcanistConfiguration extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildAllWorkflows() {
|
public function buildAllWorkflows() {
|
||||||
$workflows_by_name = array();
|
return id(new PhutilClassMapQuery())
|
||||||
|
|
||||||
$workflows_by_class_name = id(new PhutilSymbolLoader())
|
|
||||||
->setAncestorClass('ArcanistWorkflow')
|
->setAncestorClass('ArcanistWorkflow')
|
||||||
->loadObjects();
|
->setUniqueMethod('getWorkflowName')
|
||||||
foreach ($workflows_by_class_name as $class => $workflow) {
|
->execute();
|
||||||
$name = $workflow->getWorkflowName();
|
|
||||||
|
|
||||||
if (isset($workflows_by_name[$name])) {
|
|
||||||
$other = get_class($workflows_by_name[$name]);
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
'Workflows %s and %s both implement workflows named %s.',
|
|
||||||
$class,
|
|
||||||
$other,
|
|
||||||
$name));
|
|
||||||
}
|
|
||||||
|
|
||||||
$workflows_by_name[$name] = $workflow;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $workflows_by_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function isValidWorkflow($workflow) {
|
final public function isValidWorkflow($workflow) {
|
||||||
|
|
|
@ -137,36 +137,10 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadAvailableLinters() {
|
private function loadAvailableLinters() {
|
||||||
$linters = id(new PhutilSymbolLoader())
|
return id(new PhutilClassMapQuery())
|
||||||
->setAncestorClass('ArcanistLinter')
|
->setAncestorClass('ArcanistLinter')
|
||||||
->loadObjects();
|
->setUniqueMethod('getLinterConfigurationName', true)
|
||||||
|
->execute();
|
||||||
$map = array();
|
|
||||||
foreach ($linters as $linter) {
|
|
||||||
$name = $linter->getLinterConfigurationName();
|
|
||||||
|
|
||||||
// This linter isn't selectable through configuration.
|
|
||||||
if ($name === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($map[$name])) {
|
|
||||||
$map[$name] = $linter;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$orig_class = get_class($map[$name]);
|
|
||||||
$this_class = get_class($linter);
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
"Two linters (`%s`, `%s`) both have the same configuration ".
|
|
||||||
"name ('%s'). Linters must have unique configuration names.",
|
|
||||||
$orig_class,
|
|
||||||
$this_class,
|
|
||||||
$name));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function matchPaths(
|
private function matchPaths(
|
||||||
|
|
|
@ -76,11 +76,9 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine {
|
||||||
private function getAllTests() {
|
private function getAllTests() {
|
||||||
$project_root = $this->getWorkingCopy()->getProjectRoot();
|
$project_root = $this->getWorkingCopy()->getProjectRoot();
|
||||||
|
|
||||||
$symbols = id(new PhutilSymbolLoader())
|
$symbols = id(new PhutilClassMapQuery())
|
||||||
->setType('class')
|
|
||||||
->setAncestorClass('PhutilTestCase')
|
->setAncestorClass('PhutilTestCase')
|
||||||
->setConcreteOnly(true)
|
->execute();
|
||||||
->selectSymbolsWithoutLoading();
|
|
||||||
|
|
||||||
$in_working_copy = array();
|
$in_working_copy = array();
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,9 @@ EOTEXT
|
||||||
public function run() {
|
public function run() {
|
||||||
$console = PhutilConsole::getConsole();
|
$console = PhutilConsole::getConsole();
|
||||||
|
|
||||||
$linters = id(new PhutilSymbolLoader())
|
$linters = id(new PhutilClassMapQuery())
|
||||||
->setAncestorClass('ArcanistLinter')
|
->setAncestorClass('ArcanistLinter')
|
||||||
->loadObjects();
|
->execute();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$built = $this->newLintEngine()->buildLinters();
|
$built = $this->newLintEngine()->buildLinters();
|
||||||
|
|
Loading…
Reference in a new issue