Page MenuHomePhabricator

Extend nodes in both directions in XHPAST
ClosedPublic

Authored by epriestley on Jan 7 2015, 1:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Aug 7, 10:24 AM
Unknown Object (File)
Apr 16 2026, 12:14 PM
Unknown Object (File)
Mar 29 2026, 8:45 AM
Unknown Object (File)
Mar 10 2026, 12:11 AM
Unknown Object (File)
Mar 9 2026, 5:46 PM
Unknown Object (File)
Mar 3 2026, 7:40 PM
Unknown Object (File)
Jan 31 2026, 12:10 PM
Unknown Object (File)
Jan 31 2026, 12:10 PM
Subscribers

Details

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.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable