]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Call willLintPath() in future linter
authorvrana <jakubv@fb.com>
Thu, 21 Feb 2013 09:22:25 +0000 (01:22 -0800)
committervrana <jakubv@fb.com>
Thu, 21 Feb 2013 19:57:38 +0000 (11:57 -0800)
Summary: Also simplify creating futures.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, s.o.butler
Differential Revision: https://secure.phabricator.com/D5042

src/lint/linter/ArcanistFutureLinter.php
src/lint/linter/ArcanistPEP8Linter.php
src/lint/linter/ArcanistXHPASTLinter.php

index 93eef514bf0a2d076b9138bc01d4f2e98a930b69..7b5fb775de960fe0b67553864a09cb6f0d77894a 100644 (file)
@@ -7,13 +7,15 @@ abstract class ArcanistFutureLinter extends ArcanistLinter {
   abstract protected function buildFutures(array $paths);
   abstract protected function resolveFuture($path, Future $future);
 
+  protected function getFuturesLimit() {
+    return 8;
+  }
+
   public function willLintPaths(array $paths) {
-    $this->futures = $this->buildFutures($paths);
-    if (is_array($this->futures)) {
-      foreach ($this->futures as $future) {
-        $future->isReady();
-      }
-      $this->futures = Futures($this->futures);
+    $limit = $this->getFuturesLimit();
+    $this->futures = Futures(array())->limit($limit);
+    foreach ($this->buildFutures($paths) as $path => $future) {
+      $this->futures->addFuture($future, $path);
     }
   }
 
@@ -23,6 +25,7 @@ abstract class ArcanistFutureLinter extends ArcanistLinter {
   public function didRunLinters() {
     if ($this->futures) {
       foreach ($this->futures as $path => $future) {
+        $this->willLintPath($path);
         $this->resolveFuture($path, $future);
       }
     }
index 319482ffd28aa36e99c52ac5849d60c8c9bde90b..f798bf088d6b0a05af48ec8992a1f2f07b07ba0d 100644 (file)
@@ -86,16 +86,14 @@ final class ArcanistPEP8Linter extends ArcanistFutureLinter {
     $pep8_bin = $this->getPEP8Path();
     $options = $this->getPEP8Options();
 
-    $futures = Futures(array())->limit(8);
+    $futures = array();
 
     foreach ($paths as $path) {
-      $future = new ExecFuture(
+      $futures[$path] = new ExecFuture(
         "%C %C %s",
         $pep8_bin,
         $options,
         $this->getEngine()->getFilePathOnDisk($path));
-
-      $futures->addFuture($future, $path);
     }
 
     return $futures;
index 0c10527e09e5606aaa7548e2e44a58c9ae16c953..0843ea81a21995ab56689b98c369a97fb40958ca 100644 (file)
@@ -125,19 +125,16 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
   }
 
   protected function buildFutures(array $paths) {
-    $futures = Futures(array())->limit(8);
     foreach ($paths as $path) {
       if (!isset($this->futures[$path])) {
         $this->futures[$path] = xhpast_get_parser_future($this->getData($path));
       }
-      $futures->addFuture($this->futures[$path], $path);
     }
-    return $futures;
+    return array_select_keys($this->futures, $paths);
   }
 
   public function getXHPASTTreeForPath($path) {
     if (!array_key_exists($path, $this->trees)) {
-      $this->willLintPath($path);
       $this->trees[$path] = null;
       try {
         $this->trees[$path] = XHPASTTree::newFromDataAndResolvedExecFuture(