aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/core
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-24 01:22:08 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-24 01:22:08 +0200
commit99a38d4d08cb020182663ffaf9418d28becf1fd6 (patch)
tree8831e47ab817d5783f868e0f11905632faaeca5c /src/lombok/core
parentc834e09af460715a159506c5e809b3572dc22de5 (diff)
downloadlombok-99a38d4d08cb020182663ffaf9418d28becf1fd6.tar.gz
lombok-99a38d4d08cb020182663ffaf9418d28becf1fd6.tar.bz2
lombok-99a38d4d08cb020182663ffaf9418d28becf1fd6.zip
Added proper support for changing the AST as its being visited, both removal and addition. The rule is now: children traversal traverses through the tree mostly as it was when it started.
Diffstat (limited to 'src/lombok/core')
-rw-r--r--src/lombok/core/AST.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lombok/core/AST.java b/src/lombok/core/AST.java
index c1186d24..8e060f07 100644
--- a/src/lombok/core/AST.java
+++ b/src/lombok/core/AST.java
@@ -134,7 +134,7 @@ public abstract class AST<N> {
}
public Collection<? extends Node> down() {
- return children;
+ return new ArrayList<Node>(children);
}
public boolean isHandled() {
@@ -154,13 +154,18 @@ public abstract class AST<N> {
return fileName;
}
- public Node add(N newChild, Kind kind) {
+ @SuppressWarnings("unchecked") public Node add(N newChild, Kind kind) {
Node n = buildTree(newChild, kind);
if ( n == null ) return null;
n.parent = this;
+ ((List)children).add(n);
return n;
}
+ public void removeChild(Node child) {
+ children.remove(child);
+ }
+
public Node recursiveSetHandled() {
this.handled = true;
for ( Node child : children ) child.recursiveSetHandled();