From a23d77f5804f4ac91c48cf78e21905960d45e179 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Dec 2009 18:17:29 +0100 Subject: Started working on delombok without a file --- .../lombok/delombok/CommentPreservingParser.java | 19 +++++++++++++++++-- 1 file 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); -- cgit