aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <roels@.tis.local>2009-12-04 18:17:29 +0100
committerunknown <roels@.tis.local>2009-12-04 18:17:29 +0100
commita23d77f5804f4ac91c48cf78e21905960d45e179 (patch)
treef4861d75458f5c5ebae02598484a6a7d3ef7cc71
parent51972823663c59bcfcee891db274f8608e413e40 (diff)
downloadlombok-a23d77f5804f4ac91c48cf78e21905960d45e179.tar.gz
lombok-a23d77f5804f4ac91c48cf78e21905960d45e179.tar.bz2
lombok-a23d77f5804f4ac91c48cf78e21905960d45e179.zip
Started working on delombok without a file
-rw-r--r--src/delombok/lombok/delombok/CommentPreservingParser.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/delombok/lombok/delombok/CommentPreservingParser.java b/src/delombok/lombok/delombok/CommentPreservingParser.java
index 2f1de8e5..0872daa3 100644
--- a/src/delombok/lombok/delombok/CommentPreservingParser.java
+++ b/src/delombok/lombok/delombok/CommentPreservingParser.java
@@ -53,7 +53,15 @@ public class CommentPreservingParser {
this.encoding = encoding;
}
+ public ParseResult parse(JavaFileObject source, boolean forceProcessing) throws IOException {
+ return doParse(source, forceProcessing);
+ }
+
public ParseResult parse(String fileName, boolean forceProcessing) throws IOException {
+ return doParse(fileName, forceProcessing);
+ }
+
+ private ParseResult doParse(Object source, boolean forceProcessing) throws IOException {
Context context = new Context();
Options.instance(context).put(OptionName.ENCODING, encoding);
@@ -73,8 +81,15 @@ public class CommentPreservingParser {
comments.comments = List.nil();
- @SuppressWarnings("deprecation")
- JCCompilationUnit cu = compiler.parse(fileName);
+ JCCompilationUnit cu;
+ if (source instanceof JavaFileObject) {
+ cu = compiler.parse((JavaFileObject) source);
+ }
+ else {
+ @SuppressWarnings("deprecation")
+ JCCompilationUnit unit = compiler.parse((String)source);
+ cu = unit;
+ }
boolean changed = new JavacTransformer(messager).transform(context, Collections.singleton(cu));
return new ParseResult(comments.comments, cu, forceProcessing || changed);