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)
Fri, May 3, 3:37 AM
Unknown Object (File)
Mon, Apr 29, 3:33 PM
Unknown Object (File)
Wed, Apr 24, 11:32 PM
Unknown Object (File)
Wed, Apr 24, 4:50 AM
Unknown Object (File)
Wed, Apr 24, 4:50 AM
Unknown Object (File)
Wed, Apr 24, 4:50 AM
Unknown Object (File)
Wed, Apr 24, 4:50 AM
Unknown Object (File)
Wed, Apr 24, 4:50 AM
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 8052
Build 9138: [Placeholder Plan] Wait for 30 Seconds
Build 9137: 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
259–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;