Page MenuHomePhabricator

Add previous and next sibling pointers to `AASTNode`
ClosedPublic

Authored by joshuaspence on Nov 17 2015, 4:20 AM.
Tags
None
Referenced Files
F18789031: D14496.id35087.diff
Wed, Oct 15, 7:36 AM
F18740532: D14496.id35069.diff
Thu, Oct 2, 3:55 AM
F18696648: D14496.id35072.diff
Sat, Sep 27, 8:10 AM
F18611571: D14496.diff
Sep 14 2025, 7:27 AM
F18523972: D14496.diff
Sep 6 2025, 11:30 AM
F18177958: D14496.id35069.diff
Aug 16 2025, 12:47 AM
F18174013: D14496.id35072.diff
Aug 15 2025, 8:11 PM
F18141276: D14496.diff
Aug 14 2025, 7:19 AM
Subscribers

Details

Summary

Adds AASTNode::$previousSibling and AASTNode::$nextSibling properties. The primary use case is for writing a custom linter rule.

Test Plan

Tested in my custom linter rule.

Diff Detail

Repository
rPHU libphutil
Branch
master
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/parser/xhpast/api/XHPASTNode.php:245XHP55Unnecessary `final` Modifier
Unit
Tests Passed
Build Status
Buildable 8879
Build 10389: Run Core Tests
Build 10388: arc lint + arc unit

Event Timeline

joshuaspence retitled this revision from to Add a `XHPAST::getNamespace` method.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)

Actually, this is still generally useful, with some minor modifications.

joshuaspence retitled this revision from Add a `XHPAST::getNamespace` method to Add previous and next sibling pointers to `AASTNode`.Nov 17 2015, 9:32 AM
joshuaspence updated this object.
joshuaspence edited edge metadata.
joshuaspence edited the test plan for this revision. (Show Details)

Does this affect the time required to construct a large tree? I recall buildTree() being expensive in the past.

Does this affect the time required to construct a large tree? I recall buildTree() being expensive in the past.

It doesn't seem like it does... Using the following script as a benchmark:

1<?php
2
3require_once __DIR__.'/scripts/__init_script__.php';
4
5$console = PhutilConsole::getConsole();
6$iterations = 10;
7$source = Filesystem::readFile(__DIR__.'/../phabricator/src/__phutil_library_map__.php');
8$start = microtime(true);
9
10for ($ii = 0; $ii < $iterations; $ii++) {
11 XHPASTTree::newFromData($source);
12}
13
14$end = microtime(true);
15$duration = $end - $start;
16
17$console->writeOut("Average: %fs\n", $duration / $iterations);
18$console->writeOut("Total: %fs\n", $duration);

(The library map from rP is the largest PHP source file that I could easily find at 656K or 8158 lines)

Before
Average: 2.281007s
Total:   22.810069s
After
Average: 2.041991s
Total:   20.419912s
This revision is now accepted and ready to land.Nov 17 2015, 8:35 PM
This revision was automatically updated to reflect the committed changes.