From 49f0bc1c3ede3c81754568af22fcdbbe8f4b5a8f Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 17 Oct 2016 23:03:32 +0200 Subject: Cleanup --- src/core/lombok/core/AST.java | 17 +++++++++-------- src/core/lombok/eclipse/EclipseAST.java | 6 +++--- src/core/lombok/javac/JavacAST.java | 7 +++---- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/core/lombok') diff --git a/src/core/lombok/core/AST.java b/src/core/lombok/core/AST.java index 2d5e5352..1142018f 100644 --- a/src/core/lombok/core/AST.java +++ b/src/core/lombok/core/AST.java @@ -62,12 +62,18 @@ public abstract class AST, L extends LombokNode, Map identityDetector = new IdentityHashMap(); private Map nodeMap = new IdentityHashMap(); private boolean changed = false; + + // The supertypes which are considered AST Node children. Usually, the Statement, and the Expression, + // though some platforms (such as Eclipse) group these under one common supertype. + private final Collection> statementTypes; + private static final HistogramTracker configTracker = System.getProperty("lombok.timeConfig") == null ? null : new HistogramTracker("lombok.config"); - protected AST(String fileName, String packageDeclaration, ImportList imports) { + protected AST(String fileName, String packageDeclaration, ImportList imports, Collection> statementTypes) { this.fileName = fileName == null ? "(unknown).java" : fileName; this.packageDeclaration = packageDeclaration; this.imports = imports; + this.statementTypes = statementTypes; } /** @@ -262,13 +268,8 @@ public abstract class AST, L extends LombokNode, return Object.class; } - /** - * The supertypes which are considered AST Node children. Usually, the Statement, and the Expression, - * though some platforms (such as Eclipse) group these under one common supertype. */ - protected abstract Collection> getStatementTypes(); - - protected boolean shouldDrill(Class parentType, Class childType, String fieldName) { - for (Class statementType : getStatementTypes()) { + private boolean shouldDrill(Class parentType, Class childType, String fieldName) { + for (Class statementType : statementTypes) { if (statementType.isAssignableFrom(childType)) return true; } diff --git a/src/core/lombok/eclipse/EclipseAST.java b/src/core/lombok/eclipse/EclipseAST.java index 6741b33a..dc2c9843 100644 --- a/src/core/lombok/eclipse/EclipseAST.java +++ b/src/core/lombok/eclipse/EclipseAST.java @@ -62,7 +62,7 @@ public class EclipseAST extends AST { * @param ast The compilation unit, which serves as the top level node in the tree to be built. */ public EclipseAST(CompilationUnitDeclaration ast) { - super(toFileName(ast), packageDeclaration(ast), new EclipseImportList(ast)); + super(toFileName(ast), packageDeclaration(ast), new EclipseImportList(ast), statementTypes()); this.compilationUnitDeclaration = ast; setTop(buildCompilationUnit(ast)); this.completeParse = isComplete(ast); @@ -477,9 +477,9 @@ public class EclipseAST extends AST { return putInMap(new EclipseNode(this, statement, childNodes, Kind.STATEMENT)); } - /** For Eclipse, only Statement counts, as Expression is a subclass of it, even though this isn't + /* For Eclipse, only Statement counts, as Expression is a subclass of it, even though this isn't * entirely correct according to the JLS spec (only some expressions can be used as statements, not all of them). */ - @Override protected Collection> getStatementTypes() { + private static Collection> statementTypes() { return Collections.>singleton(Statement.class); } diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index 3130e7a5..106a29ae 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -81,7 +81,7 @@ public class JavacAST extends AST { * @param top The compilation unit, which serves as the top level node in the tree to be built. */ public JavacAST(Messager messager, Context context, JCCompilationUnit top) { - super(sourceName(top), PackageName.getPackageName(top), new JavacImportList(top)); + super(sourceName(top), PackageName.getPackageName(top), new JavacImportList(top), statementTypes()); setTop(buildCompilationUnit(top)); this.context = context; this.messager = messager; @@ -383,9 +383,8 @@ public class JavacAST extends AST { } } - /** For javac, both JCExpression and JCStatement are considered as valid children types. */ - @Override - protected Collection> getStatementTypes() { + /* For javac, both JCExpression and JCStatement are considered as valid children types. */ + private static Collection> statementTypes() { Collection> collection = new ArrayList>(3); collection.add(JCStatement.class); collection.add(JCExpression.class); -- cgit