Changeset View
Standalone View
src/lint/linter/ArcanistXHPASTLinter.php
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | public function setLinterConfigurationValue($key, $value) { | ||||
return parent::setLinterConfigurationValue($key, $value); | return parent::setLinterConfigurationValue($key, $value); | ||||
} | } | ||||
public function getVersion() { | public function getVersion() { | ||||
// TODO: Improve this. | // TODO: Improve this. | ||||
return count($this->rules); | return count($this->rules); | ||||
} | } | ||||
protected function resolveFuture($path, Future $future) { | protected function lintPath(ArcanistWorkingCopyPath $path) { | ||||
amckinley: This is gone because we're no longer subclassing `ArcanistFutureLinter`, right? | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsRight, I basically replaced a whole big fancy Future mechanism with "run the futures one at a time" to get this working. This likely causes a significant performance regression in arc lint, but it doesn't run yet so that's moot for now. I expect to restore futures later, but hope to find a simpler implementation. It doesn't matter for unit tests since unit tests don't run in parallel with one another (which seems like a good thing), so the performance is the same either way. The implementation was actually doing two different things:
But the way (2) got implemented was very messy and very "make it work without changing the architecture". Once I move my focus to arc lint I expect to revisit this stuff and try to find a cleaner approach for it. epriestley: Right, I basically replaced a whole big fancy Future mechanism with "run the futures one at a… | |||||
$tree = $this->getXHPASTTreeForPath($path); | $data = $path->getData(); | ||||
if (!$tree) { | |||||
$ex = $this->getXHPASTExceptionForPath($path); | try { | ||||
$future = PhutilXHPASTBinary::getParserFuture($data); | |||||
$tree = XHPASTTree::newFromDataAndResolvedExecFuture( | |||||
$data, | |||||
$future->resolve()); | |||||
$root = $tree->getRootNode(); | |||||
$root->buildSelectCache(); | |||||
$root->buildTokenCache(); | |||||
} catch (Exception $ex) { | |||||
if ($ex instanceof XHPASTSyntaxErrorException) { | if ($ex instanceof XHPASTSyntaxErrorException) { | ||||
$this->raiseLintAtLine( | $this->raiseLintAtLine( | ||||
$ex->getErrorLine(), | $ex->getErrorLine(), | ||||
1, | 1, | ||||
ArcanistSyntaxErrorXHPASTLinterRule::ID, | ArcanistSyntaxErrorXHPASTLinterRule::ID, | ||||
pht( | pht( | ||||
'This file contains a syntax error: %s', | 'This file contains a syntax error: %s', | ||||
$ex->getMessage())); | $ex->getMessage())); | ||||
} else if ($ex instanceof Exception) { | } else if ($ex instanceof Exception) { | ||||
$this->raiseLintAtPath( | $this->raiseLintAtPath( | ||||
ArcanistUnableToParseXHPASTLinterRule::ID, | ArcanistUnableToParseXHPASTLinterRule::ID, | ||||
$ex->getMessage()); | $ex->getMessage()); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
$root = $tree->getRootNode(); | |||||
foreach ($this->rules as $rule) { | foreach ($this->rules as $rule) { | ||||
if ($this->isCodeEnabled($rule->getLintID())) { | if ($this->isCodeEnabled($rule->getLintID())) { | ||||
$rule->setLinter($this); | $rule->setLinter($this); | ||||
$rule->process($root); | $rule->process($root); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
This is gone because we're no longer subclassing ArcanistFutureLinter, right?