1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-29 10:12:41 +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) { foreach ($methods as $method) {
$modifiers = $this->getModifiers($method); $modifiers = $this->getModifiers($method);
$body = $method->getChildByIndex(5); $body = $method->getChildByIndex(6);
if (idx($modifiers, 'abstract') && $body->getTypeName() != 'n_EMPTY') { if (idx($modifiers, 'abstract') && $body->getTypeName() != 'n_EMPTY') {
$this->raiseLintAtNode( $this->raiseLintAtNode(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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