Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13978572
D14496.id35087.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14496.id35087.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D14496: Add previous and next sibling pointers to `AASTNode`
Attached
Detach File
Event Timeline
Log In to Comment