mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 12:15:00 +00:00
position now set for all code generated by javac handlers;
this also solves the AssertionError in the Bits class on javac8-ea.
This commit is contained in:
1 parent
9ed14b8cbf
commit
df69425550
2 files changed
+14
-7
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user