diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 3 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 18 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index c245d506..65997f9a 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -97,6 +97,7 @@ public class JavacHandlerUtil { } @Override public void scan(JCTree tree) { + if (tree == null) return; setGeneratedBy(tree, source); super.scan(tree); } @@ -134,10 +135,12 @@ public class JavacHandlerUtil { } public static <T extends JCTree> T setGeneratedBy(T node, JCTree source) { + if (node == null) return null; synchronized (generatedNodes) { if (source == null) generatedNodes.remove(node); else generatedNodes.put(node, new WeakReference<JCTree>(source)); } + if (source != null) node.pos = source.pos; return node; } diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 7291ac29..473afb5c 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -30,6 +30,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.Writer; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URI; @@ -49,6 +50,7 @@ import javax.tools.JavaFileObject; import lombok.Lombok; import lombok.javac.CommentCatcher; import lombok.javac.LombokOptions; +import lombok.javac.apt.Processor; import com.sun.tools.javac.comp.Todo; import com.sun.tools.javac.main.JavaCompiler; @@ -363,7 +365,7 @@ public class Delombok { if (classpath != null) options.putJavacOption("CLASSPATH", classpath); if (sourcepath != null) options.putJavacOption("SOURCEPATH", sourcepath); if (bootclasspath != null) options.putJavacOption("BOOTCLASSPATH", bootclasspath); - options.put("compilePolicy", "attr"); + options.put("compilePolicy", "check"); CommentCatcher catcher = CommentCatcher.create(context); JavaCompiler compiler = catcher.getCompiler(); @@ -374,10 +376,7 @@ public class Delombok { compiler.initProcessAnnotations(Collections.singleton(new lombok.javac.apt.Processor())); for (File fileToParse : filesToParse) { - - @SuppressWarnings("deprecation") - JCCompilationUnit unit = compiler.parse(fileToParse.getAbsolutePath()); - + @SuppressWarnings("deprecation") JCCompilationUnit unit = compiler.parse(fileToParse.getAbsolutePath()); baseMap.put(unit, fileToBase.get(fileToParse)); roots.add(unit); } @@ -386,8 +385,13 @@ public class Delombok { return false; } - JavaCompiler delegate = compiler.processAnnotations(compiler.enterTrees(toJavacList(roots))); - callFlowMethodOnJavaCompiler(delegate, callAttributeMethodOnJavaCompiler(delegate, delegate.todo)); + com.sun.tools.javac.util.List<JCCompilationUnit> trees = compiler.enterTrees(toJavacList(roots)); + + JavaCompiler delegate = compiler.processAnnotations(trees); + + Object care = callAttributeMethodOnJavaCompiler(delegate, delegate.todo); + + callFlowMethodOnJavaCompiler(delegate, care); for (JCCompilationUnit unit : roots) { DelombokResult result = new DelombokResult(catcher.getComments(unit), unit, force || options.isChanged(unit)); if (verbose) feedback.printf("File: %s [%s]\n", unit.sourcefile.getName(), result.isChanged() ? "delomboked" : "unchanged"); |