aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok/javac/java7/CommentCollectingScanner.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/lombok/javac/java7/CommentCollectingScanner.java')
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingScanner.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/utils/lombok/javac/java7/CommentCollectingScanner.java b/src/utils/lombok/javac/java7/CommentCollectingScanner.java
index 2c588175..c1aec385 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingScanner.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingScanner.java
@@ -26,22 +26,21 @@ import java.nio.CharBuffer;
import lombok.javac.Comment;
import lombok.javac.Comment.EndConnection;
import lombok.javac.Comment.StartConnection;
-import lombok.javac.Comments;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.parser.Scanner;
public class CommentCollectingScanner extends Scanner {
- private final Comments comments;
+ private final ListBuffer<Comment> comments = ListBuffer.lb();
private int endComment = 0;
- public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer, Comments comments) {
+ public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer) {
super(factory, charBuffer);
- this.comments = comments;
}
- public CommentCollectingScanner(CommentCollectingScannerFactory factory, char[] input, int inputLength, Comments comments) {
+ public CommentCollectingScanner(CommentCollectingScannerFactory factory, char[] input, int inputLength) {
super(factory, input, inputLength);
- this.comments = comments;
}
@Override
@@ -55,7 +54,7 @@ public class CommentCollectingScanner extends Scanner {
EndConnection end = determineEndConnection(endPos);
Comment comment = new Comment(prevEndPos, pos, endPos, content, start, end);
- comments.add(comment);
+ comments.append(comment);
}
private EndConnection determineEndConnection(int pos) {
@@ -72,7 +71,7 @@ public class CommentCollectingScanner extends Scanner {
return first ? EndConnection.DIRECT_AFTER_COMMENT : EndConnection.AFTER_COMMENT;
}
}
-
+
private StartConnection determineStartConnection(int from, int to) {
if (from == to) {
return StartConnection.DIRECT_AFTER_PREVIOUS;
@@ -88,8 +87,12 @@ public class CommentCollectingScanner extends Scanner {
}
return StartConnection.AFTER_PREVIOUS;
}
-
+
private boolean isNewLine(char c) {
return c == '\n' || c == '\r';
}
+
+ public List<Comment> getComments() {
+ return comments.toList();
+ }
}