1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

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
This commit is contained in:
vrana 2013-02-21 01:22:25 -08:00
parent 3136edf9de
commit 459251a8d0
3 changed files with 12 additions and 14 deletions

View file

@ -7,13 +7,15 @@ abstract class ArcanistFutureLinter extends ArcanistLinter {
abstract protected function buildFutures(array $paths); abstract protected function buildFutures(array $paths);
abstract protected function resolveFuture($path, Future $future); abstract protected function resolveFuture($path, Future $future);
public function willLintPaths(array $paths) { protected function getFuturesLimit() {
$this->futures = $this->buildFutures($paths); return 8;
if (is_array($this->futures)) {
foreach ($this->futures as $future) {
$future->isReady();
} }
$this->futures = Futures($this->futures);
public function willLintPaths(array $paths) {
$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() { public function didRunLinters() {
if ($this->futures) { if ($this->futures) {
foreach ($this->futures as $path => $future) { foreach ($this->futures as $path => $future) {
$this->willLintPath($path);
$this->resolveFuture($path, $future); $this->resolveFuture($path, $future);
} }
} }

View file

@ -86,16 +86,14 @@ final class ArcanistPEP8Linter extends ArcanistFutureLinter {
$pep8_bin = $this->getPEP8Path(); $pep8_bin = $this->getPEP8Path();
$options = $this->getPEP8Options(); $options = $this->getPEP8Options();
$futures = Futures(array())->limit(8); $futures = array();
foreach ($paths as $path) { foreach ($paths as $path) {
$future = new ExecFuture( $futures[$path] = new ExecFuture(
"%C %C %s", "%C %C %s",
$pep8_bin, $pep8_bin,
$options, $options,
$this->getEngine()->getFilePathOnDisk($path)); $this->getEngine()->getFilePathOnDisk($path));
$futures->addFuture($future, $path);
} }
return $futures; return $futures;

View file

@ -125,19 +125,16 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
} }
protected function buildFutures(array $paths) { protected function buildFutures(array $paths) {
$futures = Futures(array())->limit(8);
foreach ($paths as $path) { foreach ($paths as $path) {
if (!isset($this->futures[$path])) { if (!isset($this->futures[$path])) {
$this->futures[$path] = xhpast_get_parser_future($this->getData($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) { public function getXHPASTTreeForPath($path) {
if (!array_key_exists($path, $this->trees)) { if (!array_key_exists($path, $this->trees)) {
$this->willLintPath($path);
$this->trees[$path] = null; $this->trees[$path] = null;
try { try {
$this->trees[$path] = XHPASTTree::newFromDataAndResolvedExecFuture( $this->trees[$path] = XHPASTTree::newFromDataAndResolvedExecFuture(