Bugfix: in JavacNode intintializers were not structurally significant

This commit is contained in:
Roel Spilker committed 2010-07-25 01:49:29 +02:00
1 parent 304f57bd05
commit 9bc4632315
3 files changed
+12 -5

No files matched your search

+7 -3
View File
@@ -70,8 +70,12 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A,
this.kind = kind;
this.node = node;
this.children = children == null ? new ArrayList<L>() : children;
for (L child : this.children) child.parent = (L) this;
this.isStructurallySignificant = calculateIsStructurallySignificant();
for (L child : this.children) {
child.parent = (L) this;
if (!child.isStructurallySignificant)
child.isStructurallySignificant = calculateIsStructurallySignificant(node);
}
this.isStructurallySignificant = calculateIsStructurallySignificant(null);
}
/** {@inheritDoc} */
@@ -101,7 +105,7 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A,
/**
* See {@link #isStructurallySignificant}.
*/
protected abstract boolean calculateIsStructurallySignificant();
protected abstract boolean calculateIsStructurallySignificant(N parent);
/**
* Convenient shortcut to the owning ast object's get method.
+1 -1
View File
@@ -165,7 +165,7 @@ public class EclipseNode extends lombok.core.LombokNode<EclipseAST, EclipseNode,
}
/** {@inheritDoc} */
@Override protected boolean calculateIsStructurallySignificant() {
@Override protected boolean calculateIsStructurallySignificant(ASTNode parent) {
if (node instanceof TypeDeclaration) return true;
if (node instanceof AbstractMethodDeclaration) return true;
if (node instanceof FieldDeclaration) return true;
+4 -1
View File
@@ -138,11 +138,14 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre
}
/** {@inheritDoc} */
@Override protected boolean calculateIsStructurallySignificant() {
@Override protected boolean calculateIsStructurallySignificant(JCTree parent) {
if (node instanceof JCClassDecl) return true;
if (node instanceof JCMethodDecl) return true;
if (node instanceof JCVariableDecl) return true;
if (node instanceof JCCompilationUnit) return true;
//Static and instance initializers
if (node instanceof JCBlock) return parent instanceof JCClassDecl;
return false;
}