mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Allow getXHPASTTreeForPath to return the tree for an arbitrary path
Summary: This allows `ArcanistBaseXHPASTLinter::getXHPASTTreeForPath` to return the parse tree for a file that wasn't explicitly linted. In my particular use case, I am writing a linter rule to determine if it is necessary to import a PHP file with `require_once` (i.e. the file consists only of class/interface definitions which are autoloadable). Test Plan: Tested externally using a custom linter. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12271
This commit is contained in:
parent
e72a43a992
commit
26c4f12a21
1 changed files with 5 additions and 1 deletions
|
@ -157,7 +157,6 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter {
|
||||||
* @task sharing
|
* @task sharing
|
||||||
*/
|
*/
|
||||||
final protected function getXHPASTTreeForPath($path) {
|
final protected function getXHPASTTreeForPath($path) {
|
||||||
|
|
||||||
// If we aren't the linter responsible for actually building the parse
|
// If we aren't the linter responsible for actually building the parse
|
||||||
// trees, go get the tree from that linter.
|
// trees, go get the tree from that linter.
|
||||||
if ($this->getXHPASTLinter() !== $this) {
|
if ($this->getXHPASTLinter() !== $this) {
|
||||||
|
@ -165,7 +164,12 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists($path, $this->trees)) {
|
if (!array_key_exists($path, $this->trees)) {
|
||||||
|
if (!array_key_exists($path, $this->futures)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->trees[$path] = null;
|
$this->trees[$path] = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->trees[$path] = XHPASTTree::newFromDataAndResolvedExecFuture(
|
$this->trees[$path] = XHPASTTree::newFromDataAndResolvedExecFuture(
|
||||||
$this->getData($path),
|
$this->getData($path),
|
||||||
|
|
Loading…
Reference in a new issue