1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Update xhpast linter rules for new function AST format

Summary: See D15678. A node containing a return type hint is added right before the statement body node. This updates all relevant linter rules to now retrieve the body from the correct index.

Test Plan: Ran `arc unit --everything`, inspected every single message to make sure all xhpast test cases succeeded. Also grepped for `getChildByIndex(5` and `getChildOfType(5`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15814
This commit is contained in:
Richard van Velzen 2016-04-28 16:59:50 +02:00
parent ea6fc77892
commit 3ffed59bd7
8 changed files with 8 additions and 8 deletions

View file

@ -14,7 +14,7 @@ final class ArcanistAbstractMethodBodyXHPASTLinterRule
foreach ($methods as $method) {
$modifiers = $this->getModifiers($method);
$body = $method->getChildByIndex(5);
$body = $method->getChildByIndex(6);
if (idx($modifiers, 'abstract') && $body->getTypeName() != 'n_EMPTY') {
$this->raiseLintAtNode(

View file

@ -16,7 +16,7 @@ final class ArcanistInterfaceMethodBodyXHPASTLinterRule
$methods = $interface->selectDescendantsOfType('n_METHOD_DECLARATION');
foreach ($methods as $method) {
$body = $method->getChildByIndex(5);
$body = $method->getChildByIndex(6);
if ($body->getTypeName() != 'n_EMPTY') {
$this->raiseLintAtNode(

View file

@ -46,7 +46,7 @@ final class ArcanistReusedAsIteratorXHPASTLinterRule
$vars[] = $var;
}
$body = $def->getChildByIndex(5);
$body = $def->getChildByIndex(6);
if ($body->getTypeName() === 'n_EMPTY') {
// Abstract method declaration.
continue;

View file

@ -31,7 +31,7 @@ final class ArcanistReusedIteratorReferenceXHPASTLinterRule
));
foreach ($defs as $def) {
$body = $def->getChildByIndex(5);
$body = $def->getChildByIndex(6);
if ($body->getTypeName() === 'n_EMPTY') {
// Abstract method declaration.
continue;

View file

@ -40,7 +40,7 @@ final class ArcanistStaticThisXHPASTLinterRule
continue;
}
$body = $method->getChildOfType(5, 'n_STATEMENT_LIST');
$body = $method->getChildOfType(6, 'n_STATEMENT_LIST');
$variables = $body->selectDescendantsOfType('n_VARIABLE');
foreach ($variables as $variable) {

View file

@ -21,7 +21,7 @@ final class ArcanistToStringExceptionXHPASTLinterRule
continue;
}
$statements = $method->getChildByIndex(5);
$statements = $method->getChildByIndex(6);
if ($statements->getTypeName() != 'n_STATEMENT_LIST') {
continue;

View file

@ -88,7 +88,7 @@ final class ArcanistUndeclaredVariableXHPASTLinterRule
$vars[] = $var;
}
$body = $def->getChildByIndex(5);
$body = $def->getChildByIndex(6);
if ($body->getTypeName() === 'n_EMPTY') {
// Abstract method declaration.
continue;

View file

@ -40,7 +40,7 @@ final class ArcanistUselessOverridingMethodXHPASTLinterRule
$parameters[] = $parameter->getConcreteString();
}
$statements = $method->getChildByIndex(5);
$statements = $method->getChildByIndex(6);
if ($statements->getTypeName() != 'n_STATEMENT_LIST') {
continue;