Skip to content

Commit b7896c5

Browse files
committed
[#3824] Our own 'Comment' ad hoc impl now also needs to provide an impl for getPos().
1 parent 8ed8234 commit b7896c5

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

src/delombok/lombok/delombok/DocCommentIntegrator.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131

3232
import com.sun.tools.javac.parser.Tokens.Comment;
3333
import com.sun.tools.javac.tree.DocCommentTable;
34+
import com.sun.tools.javac.tree.EndPosTable;
3435
import com.sun.tools.javac.tree.JCTree;
3536
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
3637
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
3738
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
3839
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
40+
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
3941
import com.sun.tools.javac.tree.TreeScanner;
4042

4143
import lombok.javac.CommentInfo;
@@ -132,6 +134,35 @@ static void attach(final JCTree node, String docCommentContent, final int pos, O
132134
return docCommentContent_;
133135
}
134136

137+
@Override public DiagnosticPosition getPos() {
138+
return new DiagnosticPosition() {
139+
public JCTree getTree() {
140+
return node;
141+
}
142+
143+
public int getStartPosition() {
144+
return pos;
145+
}
146+
147+
public int getPreferredPosition() {
148+
return pos;
149+
}
150+
151+
@SuppressWarnings("unused") // We compile against very old versions of javac intentionally (to support old stuff), but this is the method for newer impls.
152+
public int getEndPosition(EndPosTable endPosTable) {
153+
int end = endPosTable == null ? 0 : endPosTable.getEndPos(node);
154+
if (end > pos) return end;
155+
return pos + docCommentContent_.length();
156+
}
157+
158+
public int getEndPosition(Map<JCTree, Integer> endPosTable) {
159+
Integer end = endPosTable.get(node);
160+
if (end != null && end.intValue() > pos) return end.intValue();
161+
return pos + docCommentContent_.length();
162+
}
163+
};
164+
}
165+
135166
@Override public int getSourcePos(int index) {
136167
return pos + index;
137168
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.sun.tools.javac.tree;
2+
3+
public interface EndPosTable {
4+
int getEndPos(JCTree tree);
5+
}

src/utils/lombok/javac/Javac.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import com.sun.tools.javac.tree.JCTree.JCImport;
5656
import com.sun.tools.javac.tree.JCTree.JCLiteral;
5757
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
58-
import com.sun.tools.javac.tree.TreeInfo;
5958
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
6059

6160
import lombok.core.ClassLiteral;

0 commit comments

Comments
 (0)