Page MenuHomePhabricator

Fix wrong indentation returned by AASTNode::getIndentation() when calling it on a statement node that is preceded by a comment token.
Needs ReviewPublic

Authored by thaiphv on Sep 15 2015, 2:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 2:41 PM
Unknown Object (File)
Fri, Nov 15, 11:47 PM
Unknown Object (File)
Tue, Nov 12, 12:44 PM
Unknown Object (File)
Sun, Nov 10, 10:47 AM
Unknown Object (File)
Sun, Nov 10, 6:11 AM
Unknown Object (File)
Sat, Nov 9, 10:07 AM
Unknown Object (File)
Fri, Nov 8, 8:49 PM
Unknown Object (File)
Fri, Nov 8, 8:49 PM
Subscribers

Details

Reviewers
joshuaspence
epriestley
Group Reviewers
Blessed Reviewers
Summary

The fix essentially also checks for comment tokens as one of the stop conditions in the while loop.

Test Plan

Ran the method against the following test code:

// comment
    $x = 1;

The indentation of the statement node must be instead of .

Diff Detail

Repository
rPHU libphutil
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 7979
Build 8987: [Placeholder Plan] Wait for 30 Seconds
Build 8986: arc lint + arc unit

Event Timeline

thaiphv retitled this revision from to Fix wrong indentation returned by AASTNode::getIndentation() when calling it on a statement node that is preceded by a comment token..
thaiphv updated this object.
thaiphv edited the test plan for this revision. (Show Details)
thaiphv added reviewers: joshuaspence, epriestley.
thaiphv edited edge metadata.
  • Ensure that a next token is available
joshuaspence edited edge metadata.

I'm not entirely sure that this is correct... I think that we should add some unit tests before pursuing this.

src/parser/aast/api/AASTNode.php
260

Prefer to use !$left->isSemantic()

This revision now requires changes to proceed.Sep 25 2015, 12:30 AM
thaiphv edited edge metadata.

Fix the review comment.

I'm not sure if PhutilTestCase supports testing abstract classes like this one.

I've tested the function myself use the cases below:

$x = 1;
// with comment
$x = 1;
/* with comment */
$x = 1;
/* with comment */ $y = 2;