[jruby-joni] 138/194: introduce RootNode to enable more consistent ast node swapping
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:35 UTC 2018
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit a665c0b00dac22eb8c4c2fff90f28e33e76e7aa3
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Wed Jan 10 22:03:03 2018 +0100
introduce RootNode to enable more consistent ast node swapping
---
src/org/joni/ast/Node.java | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/org/joni/ast/Node.java b/src/org/joni/ast/Node.java
index 1d727f5..7ff61ff 100644
--- a/src/org/joni/ast/Node.java
+++ b/src/org/joni/ast/Node.java
@@ -98,4 +98,43 @@ public abstract class Node implements NodeType {
public final boolean isSimple() {
return (getType2Bit() & SIMPLE) != 0;
}
+
+ public static RootNode newRoot(Node root) {
+ return new RootNode(root);
+ }
+
+ public static final class RootNode extends Node {
+ private Node root;
+
+ RootNode(Node root) {
+ super(-1);
+ root.parent = this;
+ setChild(root);
+ }
+
+ public Node getRoot() {
+ return root;
+ }
+
+ @Override
+ public void setChild(Node node) {
+ node.parent = this;
+ root = node;
+ }
+
+ @Override
+ public Node getChild() {
+ return root;
+ }
+
+ @Override
+ public String getName() {
+ return "ROOT";
+ }
+
+ @Override
+ public String toString(int level) {
+ return "\n" + pad(root, level + 1);
+ }
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list