]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Use PhutilClassMapQuery instead of PhutilSymbolLoader
authorJoshua Spence <josh@joshuaspence.com>
Mon, 10 Aug 2015 20:50:47 +0000 (06:50 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Mon, 10 Aug 2015 20:50:47 +0000 (06:50 +1000)
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

src/configuration/ArcanistConfiguration.php
src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
src/unit/engine/PhutilUnitTestEngine.php
src/workflow/ArcanistLintersWorkflow.php

index 711525874c69b9836607b3fddddd915f9127a5cc..91d0dc65c79ac669fabde746abfc39c3f7b93a27 100644 (file)
@@ -35,28 +35,10 @@ class ArcanistConfiguration extends Phobject {
   }
 
   public function buildAllWorkflows() {
-    $workflows_by_name = array();
-
-    $workflows_by_class_name = id(new PhutilSymbolLoader())
+    return id(new PhutilClassMapQuery())
       ->setAncestorClass('ArcanistWorkflow')
-      ->loadObjects();
-    foreach ($workflows_by_class_name as $class => $workflow) {
-      $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;
+      ->setUniqueMethod('getWorkflowName')
+      ->execute();
   }
 
   final public function isValidWorkflow($workflow) {
index 531ccf6cc76d88a04d32772aaf6465b6939a079e..9d8693afda8a91cfdda90de74bb9bd44fe7ad343 100644 (file)
@@ -137,36 +137,10 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
   }
 
   private function loadAvailableLinters() {
-    $linters = id(new PhutilSymbolLoader())
+    return id(new PhutilClassMapQuery())
       ->setAncestorClass('ArcanistLinter')
-      ->loadObjects();
-
-    $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;
+      ->setUniqueMethod('getLinterConfigurationName', true)
+      ->execute();
   }
 
   private function matchPaths(
index 7509b30040e2ef7d5f0ea6c84e57eba35f1933fe..1dd4722095394451a05e025a31433112fbe2e99c 100644 (file)
@@ -76,11 +76,9 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine {
   private function getAllTests() {
     $project_root = $this->getWorkingCopy()->getProjectRoot();
 
-    $symbols = id(new PhutilSymbolLoader())
-      ->setType('class')
+    $symbols = id(new PhutilClassMapQuery())
       ->setAncestorClass('PhutilTestCase')
-      ->setConcreteOnly(true)
-      ->selectSymbolsWithoutLoading();
+      ->execute();
 
     $in_working_copy = array();
 
index b872e300c0784f00ba7741ba7c0b9485c4de2a4b..6d70b4d6ff1d9c9bbd87d1d623b2a4e4c353da5c 100644 (file)
@@ -36,9 +36,9 @@ EOTEXT
   public function run() {
     $console = PhutilConsole::getConsole();
 
-    $linters = id(new PhutilSymbolLoader())
+    $linters = id(new PhutilClassMapQuery())
       ->setAncestorClass('ArcanistLinter')
-      ->loadObjects();
+      ->execute();
 
     try {
       $built = $this->newLintEngine()->buildLinters();