aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/delombok/lombok/delombok/CommentPreservingParser.java11
-rw-r--r--src/delombok/lombok/delombok/Delombok.java6
2 files changed, 16 insertions, 1 deletions
diff --git a/src/delombok/lombok/delombok/CommentPreservingParser.java b/src/delombok/lombok/delombok/CommentPreservingParser.java
index d48c5bf0..1cd2e5b1 100644
--- a/src/delombok/lombok/delombok/CommentPreservingParser.java
+++ b/src/delombok/lombok/delombok/CommentPreservingParser.java
@@ -30,6 +30,7 @@ import javax.annotation.processing.Messager;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
+import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import javax.tools.Diagnostic.Kind;
@@ -46,6 +47,7 @@ import com.sun.tools.javac.util.Options;
public class CommentPreservingParser {
private final String encoding;
private boolean deleteLombokAnnotations = false;
+ private DiagnosticListener<JavaFileObject> diagnostics = null;
public CommentPreservingParser() {
this("utf-8");
@@ -56,7 +58,11 @@ public class CommentPreservingParser {
}
public void setDeleteLombokAnnotations(boolean deleteLombokAnnotations) {
- this.deleteLombokAnnotations = deleteLombokAnnotations;
+ this.deleteLombokAnnotations = deleteLombokAnnotations;
+ }
+
+ public void setDiagnosticsListener(DiagnosticListener<JavaFileObject> diagnostics) {
+ this.diagnostics = diagnostics;
}
public ParseResult parse(JavaFileObject source, boolean forceProcessing) throws IOException {
@@ -72,6 +78,8 @@ public class CommentPreservingParser {
Options.instance(context).put(OptionName.ENCODING, encoding);
+ if (diagnostics != null) context.put(DiagnosticListener.class, diagnostics);
+
CommentCollectingScanner.Factory.preRegister(context);
JavaCompiler compiler = new JavaCompiler(context) {
@@ -80,6 +88,7 @@ public class CommentPreservingParser {
return true;
}
};
+
compiler.genEndPos = true;
Comments comments = new Comments();
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index 4ec5e270..56994f78 100644
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -35,6 +35,7 @@ import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.List;
+import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import lombok.delombok.CommentPreservingParser.ParseResult;
@@ -170,6 +171,11 @@ public class Delombok {
charset = Charset.forName(charsetName);
}
+
+ public void setDiagnosticsListener(DiagnosticListener<JavaFileObject> diagnostics) {
+ parser.setDiagnosticsListener(diagnostics);
+ }
+
public void setForceProcess(boolean force) {
this.force = force;
}