aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok/javac/java7
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/lombok/javac/java7')
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingParser.java8
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingParserFactory.java8
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingScanner.java19
3 files changed, 20 insertions, 15 deletions
diff --git a/src/utils/lombok/javac/java7/CommentCollectingParser.java b/src/utils/lombok/javac/java7/CommentCollectingParser.java
index 54cdb6a9..82f19c42 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingParser.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingParser.java
@@ -3,7 +3,7 @@ package lombok.javac.java7;
import java.util.List;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.parser.EndPosParser;
import com.sun.tools.javac.parser.Lexer;
@@ -11,11 +11,11 @@ import com.sun.tools.javac.parser.ParserFactory;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
class CommentCollectingParser extends EndPosParser {
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
private final Lexer lexer;
protected CommentCollectingParser(ParserFactory fac, Lexer S,
- boolean keepDocComments, boolean keepLineMap, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ boolean keepDocComments, boolean keepLineMap, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
super(fac, S, keepDocComments, keepLineMap);
lexer = S;
this.commentsMap = commentsMap;
@@ -24,7 +24,7 @@ class CommentCollectingParser extends EndPosParser {
public JCCompilationUnit parseCompilationUnit() {
JCCompilationUnit result = super.parseCompilationUnit();
if (lexer instanceof CommentCollectingScanner) {
- List<Comment> comments = ((CommentCollectingScanner)lexer).getComments();
+ List<CommentInfo> comments = ((CommentCollectingScanner)lexer).getComments();
commentsMap.put(result, comments);
}
return result;
diff --git a/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java
index 7d8c9537..e361a5bd 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java
@@ -4,7 +4,7 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.parser.Lexer;
@@ -15,14 +15,14 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Context;
public class CommentCollectingParserFactory extends ParserFactory {
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
private final Context context;
static Context.Key<ParserFactory> key() {
return parserFactoryKey;
}
- protected CommentCollectingParserFactory(Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ protected CommentCollectingParserFactory(Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
super(context);
this.context = context;
this.commentsMap = commentsMap;
@@ -38,7 +38,7 @@ public class CommentCollectingParserFactory extends ParserFactory {
//Either way this will work out.
}
- public static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ public static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
context.put(CommentCollectingParserFactory.key(), (ParserFactory)null);
Field field;
try {
diff --git a/src/utils/lombok/javac/java7/CommentCollectingScanner.java b/src/utils/lombok/javac/java7/CommentCollectingScanner.java
index b13973b1..e2d040f2 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingScanner.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingScanner.java
@@ -23,16 +23,16 @@ package lombok.javac.java7;
import java.nio.CharBuffer;
-import lombok.javac.Comment;
-import lombok.javac.Comment.EndConnection;
-import lombok.javac.Comment.StartConnection;
+import lombok.javac.CommentInfo;
+import lombok.javac.CommentInfo.EndConnection;
+import lombok.javac.CommentInfo.StartConnection;
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 ListBuffer<Comment> comments = ListBuffer.lb();
+ private final ListBuffer<CommentInfo> comments = ListBuffer.lb();
private int endComment = 0;
public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer) {
@@ -53,14 +53,19 @@ public class CommentCollectingScanner extends Scanner {
StartConnection start = determineStartConnection(prevEndPos, pos);
EndConnection end = determineEndConnection(endPos);
- Comment comment = new Comment(prevEndPos, pos, endPos, content, start, end);
+ CommentInfo comment = new CommentInfo(prevEndPos, pos, endPos, content, start, end);
comments.append(comment);
}
private EndConnection determineEndConnection(int pos) {
boolean first = true;
for (int i = pos;; i++) {
- char c = getRawCharacters(i, i + 1)[0];
+ char c;
+ try {
+ c = getRawCharacters(i, i + 1)[0];
+ } catch (IndexOutOfBoundsException e) {
+ c = '\n';
+ }
if (isNewLine(c)) {
return EndConnection.ON_NEXT_LINE;
}
@@ -92,7 +97,7 @@ public class CommentCollectingScanner extends Scanner {
return c == '\n' || c == '\r';
}
- public List<Comment> getComments() {
+ public List<CommentInfo> getComments() {
return comments.toList();
}
}