mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 12:16:49 +00:00
Bugfix: in JavacNode intintializers were not structurally significant
This commit is contained in:
1 parent
304f57bd05
commit
9bc4632315
3 files changed
+12
-5
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user