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
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);
}
}
public function didRunLinters() {
if ($this->futures) {
foreach ($this->futures as $path => $future) {
+ $this->willLintPath($path);
$this->resolveFuture($path, $future);
}
}
$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;
}
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(