mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 08:52:39 +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:
parent
3136edf9de
commit
459251a8d0
3 changed files with 12 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue