diff options
author | unknown <roels@.tis.local> | 2009-12-04 18:17:29 +0100 |
---|---|---|
committer | unknown <roels@.tis.local> | 2009-12-04 18:17:29 +0100 |
commit | a23d77f5804f4ac91c48cf78e21905960d45e179 (patch) | |
tree | f4861d75458f5c5ebae02598484a6a7d3ef7cc71 /src | |
parent | 51972823663c59bcfcee891db274f8608e413e40 (diff) | |
download | lombok-a23d77f5804f4ac91c48cf78e21905960d45e179.tar.gz lombok-a23d77f5804f4ac91c48cf78e21905960d45e179.tar.bz2 lombok-a23d77f5804f4ac91c48cf78e21905960d45e179.zip |
Started working on delombok without a file
Diffstat (limited to 'src')
-rw-r--r-- | src/delombok/lombok/delombok/CommentPreservingParser.java | 19 |
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); |