HomePhabricator

Extend nodes in both directions in XHPAST

Description

Extend nodes in both directions in XHPAST

Summary:
Currently, appendChild() extends tokens only to the right, so this produces the wrong result:

NLMORE($$, $2);
$$->apppendChild($1);

Instead of separate setBegin() + setEnd() operations, just always extend both sides of the range if applicable. This reduces NLMORE to NMORE and removes the pitfall from the codebase.

(I retained NEXTEND() because I think it makes the code a little more clear.)

Test Plan:

  • Unit tests.
  • Parsed a snippet with methods-with-modifiers and methods-without-modifiers and saw the whole method definition end up in the n_METHOD_DECLARATION node.

Reviewers: joshuaspence, richardvanvelzen

Reviewed By: richardvanvelzen

Subscribers: epriestley

Maniphest Tasks: T6885

Differential Revision: https://secure.phabricator.com/D11268

Details

Provenance
epriestleyAuthored on
epriestleyPushed on Jan 7 2015, 1:49 PM
Reviewer
richardvanvelzen
Differential Revision
D11268: Extend nodes in both directions in XHPAST
Parents
rPHU00fe30dd9ebf: Fix a minor XHPAST bug
Branches
Unknown
Tags
Unknown