Page MenuHomePhabricator

Extend nodes in both directions in XHPAST
ClosedPublic

Authored by epriestley on Jan 7 2015, 1:38 PM.
Tags
None
Referenced Files
F15482515: D11268.id27071.diff
Wed, Apr 9, 5:58 AM
F15440518: D11268.diff
Mar 26 2025, 1:08 PM
F15418500: D11268.id27071.diff
Mar 20 2025, 11:40 PM
F15412064: D11268.id27070.diff
Mar 19 2025, 11:06 AM
F15411362: D11268.id.diff
Mar 19 2025, 9:12 AM
F15405135: D11268.diff
Mar 18 2025, 10:25 AM
F15389152: D11268.diff
Mar 15 2025, 4:56 AM
F15381294: D11268.diff
Mar 14 2025, 6:54 AM
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