aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/JavacTransformer.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-11-10 22:20:08 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-11-10 22:20:08 +0100
commit40b76b50462ac2a3d25b29eb4a8d28298a474efa (patch)
tree5e9090e40a8d020d48c27dea84f093af5a9ed7bc /src/core/lombok/javac/JavacTransformer.java
parentc8774389e7cb73e494267af3a87f70c7497b220a (diff)
parent632027249b813bfabd457c07ebc89c4456e8175d (diff)
downloadlombok-40b76b50462ac2a3d25b29eb4a8d28298a474efa.tar.gz
lombok-40b76b50462ac2a3d25b29eb4a8d28298a474efa.tar.bz2
lombok-40b76b50462ac2a3d25b29eb4a8d28298a474efa.zip
Merge branch 'fixDelombok'
Diffstat (limited to 'src/core/lombok/javac/JavacTransformer.java')
-rw-r--r--src/core/lombok/javac/JavacTransformer.java46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/core/lombok/javac/JavacTransformer.java b/src/core/lombok/javac/JavacTransformer.java
index 5f145460..f9757894 100644
--- a/src/core/lombok/javac/JavacTransformer.java
+++ b/src/core/lombok/javac/JavacTransformer.java
@@ -22,7 +22,6 @@
package lombok.javac;
import java.util.ArrayList;
-import java.util.List;
import javax.annotation.processing.Messager;
@@ -32,6 +31,7 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
public class JavacTransformer {
private final HandlerLibrary handlers;
@@ -42,26 +42,46 @@ public class JavacTransformer {
this.handlers = HandlerLibrary.load(messager);
}
- public boolean transform(Context context, Iterable<JCCompilationUnit> compilationUnits) {
- List<JavacAST> asts = new ArrayList<JavacAST>();
+ public void transform(boolean postResolution, Context context, java.util.List<JCCompilationUnit> compilationUnitsRaw) {
+ List<JCCompilationUnit> compilationUnits;
+ if (compilationUnitsRaw instanceof List<?>) {
+ compilationUnits = (List<JCCompilationUnit>)compilationUnitsRaw;
+ } else {
+ compilationUnits = List.nil();
+ for (int i = compilationUnitsRaw.size() -1; i >= 0; i--) {
+ compilationUnits = compilationUnits.prepend(compilationUnitsRaw.get(i));
+ }
+ }
+
+ java.util.List<JavacAST> asts = new ArrayList<JavacAST>();
for (JCCompilationUnit unit : compilationUnits) asts.add(new JavacAST(messager, context, unit));
- handlers.skipPrintAST();
- for (JavacAST ast : asts) {
- ast.traverse(new AnnotationVisitor());
- handlers.callASTVisitors(ast);
+ if (!postResolution) {
+ handlers.setPreResolutionPhase();
+ for (JavacAST ast : asts) {
+ ast.traverse(new AnnotationVisitor());
+ handlers.callASTVisitors(ast);
+ }
}
- handlers.skipAllButPrintAST();
- for (JavacAST ast : asts) {
- ast.traverse(new AnnotationVisitor());
+ if (postResolution) {
+ handlers.setPostResolutionPhase();
+ for (JavacAST ast : asts) {
+ ast.traverse(new AnnotationVisitor());
+ handlers.callASTVisitors(ast);
+ }
+
+ handlers.setPrintASTPhase();
+ for (JavacAST ast : asts) {
+ ast.traverse(new AnnotationVisitor());
+ }
}
- for (JavacAST ast : asts) {
- if (ast.isChanged()) return true;
+ TrackChangedAsts changes = context.get(TrackChangedAsts.class);
+ if (changes != null) for (JavacAST ast : asts) {
+ if (ast.isChanged()) changes.changed.add((JCCompilationUnit) ast.top().get());
}
- return false;
}
private class AnnotationVisitor extends JavacASTAdapter {