From: vrana Date: Thu, 21 Feb 2013 09:22:25 +0000 (-0800) Subject: Call willLintPath() in future linter X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=459251a8d02a9888247f528ffa219aac0e416ac4;p=arcanist.git Call willLintPath() in future linter 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 --- diff --git a/src/lint/linter/ArcanistFutureLinter.php b/src/lint/linter/ArcanistFutureLinter.php index 93eef514..7b5fb775 100644 --- a/src/lint/linter/ArcanistFutureLinter.php +++ b/src/lint/linter/ArcanistFutureLinter.php @@ -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); } } diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php index 319482ff..f798bf08 100644 --- a/src/lint/linter/ArcanistPEP8Linter.php +++ b/src/lint/linter/ArcanistPEP8Linter.php @@ -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; diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 0c10527e..0843ea81 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -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(