From e54c3f36e3122dfe34a119178cfcca2dcdbad998 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Fri, 27 Nov 2009 03:10:03 +0100 Subject: Added change tracking so that 1 AST instance can tell you if any processor changed anything. --- src/core/lombok/core/AST.java | 13 +++++++++++++ src/core/lombok/core/LombokNode.java | 6 ++++++ src/core/lombok/eclipse/EclipseAST.java | 3 +++ src/core/lombok/javac/JavacAST.java | 1 + 4 files changed, 23 insertions(+) diff --git a/src/core/lombok/core/AST.java b/src/core/lombok/core/AST.java index 6d786d1e..e769ce34 100644 --- a/src/core/lombok/core/AST.java +++ b/src/core/lombok/core/AST.java @@ -54,11 +54,24 @@ public abstract class AST, L extends LombokNode, private final String fileName; Map identityDetector = new IdentityHashMap(); private Map nodeMap = new IdentityHashMap(); + private boolean changed = false; protected AST(String fileName) { this.fileName = fileName == null ? "(unknown).java" : fileName; } + protected void setChanged() { + this.changed = true; + } + + protected void clearChanged() { + this.changed = false; + } + + public boolean isChanged() { + return changed; + } + /** Set the node object that wraps the internal Compilation Unit node. */ protected void setTop(L top) { this.top = top; diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java index c8ee4c00..95c5a0cb 100644 --- a/src/core/lombok/core/LombokNode.java +++ b/src/core/lombok/core/LombokNode.java @@ -126,6 +126,7 @@ public abstract class LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode { this.compilationUnitDeclaration = ast; setTop(buildCompilationUnit(ast)); this.completeParse = isComplete(ast); + clearChanged(); } /** {@inheritDoc} */ @@ -201,12 +202,14 @@ public class EclipseAST extends AST { public void reparse() { propagateProblems(); if (completeParse) return; + boolean changed = isChanged(); boolean newCompleteParse = isComplete(compilationUnitDeclaration); if (!newCompleteParse) return; top().rebuild(); this.completeParse = true; + if (!changed) clearChanged(); } private static boolean isComplete(CompilationUnitDeclaration unit) { diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index 77c63cfe..93e3f3dc 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -78,6 +78,7 @@ public class JavacAST extends AST { this.nameTable = Name.Table.instance(context); this.treeMaker = TreeMaker.instance(context); this.symtab = Symtab.instance(context); + clearChanged(); } public Context getContext() { -- cgit