Fixed whitespace to project standards.

This commit is contained in:
Reinier Zwitserloot committed 2009-11-27 07:19:38 +01:00
1 parent 4316e77e1e
commit 9ac004b385
2 files changed
+35 -35

No files matched your search

@@ -29,55 +29,52 @@ import com.sun.tools.javac.parser.Scanner;
import com.sun.tools.javac.util.Context;
public class CommentCollectingScanner extends Scanner {
private final Comments comments;
private final Comments comments;
/** A factory for creating scanners. */
public static class Factory extends Scanner.Factory {
private final Context context;
public static class Factory extends Scanner.Factory {
private final Context context;
public static void preRegister(final Context context) {
context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
public CommentCollectingScanner.Factory make() {
return new Factory(context);
return new Factory(context);
}
});
});
}
/** Create a new scanner factory. */
protected Factory(Context context) {
super(context);
super(context);
this.context = context;
}
@Override
public Scanner newScanner(CharSequence input) {
if (input instanceof CharBuffer) {
return new CommentCollectingScanner(this, (CharBuffer)input, context.get(Comments.class));
}
char[] array = input.toString().toCharArray();
return newScanner(array, array.length);
}
@Override
public Scanner newScanner(CharSequence input) {
if (input instanceof CharBuffer) {
return new CommentCollectingScanner(this, (CharBuffer)input, context.get(Comments.class));
}
char[] array = input.toString().toCharArray();
return newScanner(array, array.length);
}
@Override
public Scanner newScanner(char[] input, int inputLength) {
return new CommentCollectingScanner(this, input, inputLength, context.get(Comments.class));
}
}
@Override
public Scanner newScanner(char[] input, int inputLength) {
return new CommentCollectingScanner(this, input, inputLength, context.get(Comments.class));
}
}
public CommentCollectingScanner(CommentCollectingScanner.Factory factory, CharBuffer charBuffer, Comments comments) {
super(factory, charBuffer);
this.comments = comments;
}
public CommentCollectingScanner(CommentCollectingScanner.Factory factory, char[] input, int inputLength, Comments comments) {
super(factory, input, inputLength);
this.comments = comments;
}
@Override
protected void processComment(CommentStyle style) {
int prevEndPos = prevEndPos();
@@ -86,8 +83,7 @@ public class CommentCollectingScanner extends Scanner {
String content = new String(getRawCharacters(pos, endPos()));
comments.add(prevEndPos, pos, endPos(), content, newLine);
}
private boolean containsNewLine(int from, int to) {
for (char c : getRawCharacters(from, to)) {
if (c == '\n' || c == '\r') {
@@ -96,4 +92,4 @@ public class CommentCollectingScanner extends Scanner {
}
return false;
}
}
}
@@ -43,9 +43,8 @@ import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Options;
public class CommentPreservingParser {
private final String encoding;
public CommentPreservingParser() {
this("utf-8");
}
@@ -73,6 +72,7 @@ public class CommentPreservingParser {
context.put(Comments.class, comments);
comments.comments = List.nil();
@SuppressWarnings("deprecation")
JCCompilationUnit cu = compiler.parse(fileName);
@@ -130,5 +130,9 @@ public class CommentPreservingParser {
out.write("// Generated by delombok at " + new Date() + "\n");
compilationUnit.accept(new PrettyCommentsPrinter(out, compilationUnit, comments));
}
public boolean isChanged() {
return changed;
}
}
}
}