Page MenuHomePhabricator

D14496.id35087.diff
No OneTemporary

D14496.id35087.diff

diff --git a/src/parser/aast/api/AASTNode.php b/src/parser/aast/api/AASTNode.php
--- a/src/parser/aast/api/AASTNode.php
+++ b/src/parser/aast/api/AASTNode.php
@@ -13,6 +13,8 @@
// faster; do not access them directly.
public $children = array();
public $parentNode;
+ public $previousSibling = null;
+ public $nextSibling = null;
private $selectCache;
@@ -41,6 +43,14 @@
return $this->parentNode;
}
+ final public function getPreviousSibling() {
+ return $this->previousSibling;
+ }
+
+ final public function getNextSibling() {
+ return $this->nextSibling;
+ }
+
final public function getID() {
return $this->id;
}
diff --git a/src/parser/aast/api/AASTTree.php b/src/parser/aast/api/AASTTree.php
--- a/src/parser/aast/api/AASTTree.php
+++ b/src/parser/aast/api/AASTTree.php
@@ -141,9 +141,23 @@
foreach ($nodes as $node_id => $node) {
if (isset($node[3])) {
$children = $this->buildTree($node[3]);
- foreach ($children as $child) {
+ $previous_child = null;
+
+ foreach ($children as $ii => $child) {
$child->parentNode = $this->tree[$node_id];
+ $child->previousSibling = $previous_child;
+
+ if ($previous_child) {
+ $previous_child->nextSibling = $child;
+ }
+
+ $previous_child = $child;
}
+
+ if ($previous_child) {
+ $previous_child->nextSibling = $child;
+ }
+
$this->tree[$node_id]->children = $children;
}
}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 19, 11:52 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712656
Default Alt Text
D14496.id35087.diff (1 KB)

Event Timeline