diff options
-rw-r--r-- | src/core/lombok/core/LombokNode.java | 10 | ||||
-rw-r--r-- | src/core/lombok/eclipse/EclipseNode.java | 2 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacNode.java | 5 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java index 1d080c59..6fe37a6b 100644 --- a/src/core/lombok/core/LombokNode.java +++ b/src/core/lombok/core/LombokNode.java @@ -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. diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java index 50edda58..e6fd1b03 100644 --- a/src/core/lombok/eclipse/EclipseNode.java +++ b/src/core/lombok/eclipse/EclipseNode.java @@ -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; diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java index 3f513887..8bbd007f 100644 --- a/src/core/lombok/javac/JavacNode.java +++ b/src/core/lombok/javac/JavacNode.java @@ -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; } |