|
31 | 31 |
|
32 | 32 | import com.sun.tools.javac.parser.Tokens.Comment; |
33 | 33 | import com.sun.tools.javac.tree.DocCommentTable; |
| 34 | +import com.sun.tools.javac.tree.EndPosTable; |
34 | 35 | import com.sun.tools.javac.tree.JCTree; |
35 | 36 | import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
36 | 37 | import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
37 | 38 | import com.sun.tools.javac.tree.JCTree.JCMethodDecl; |
38 | 39 | import com.sun.tools.javac.tree.JCTree.JCVariableDecl; |
| 40 | +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
39 | 41 | import com.sun.tools.javac.tree.TreeScanner; |
40 | 42 |
|
41 | 43 | import lombok.javac.CommentInfo; |
@@ -132,6 +134,35 @@ static void attach(final JCTree node, String docCommentContent, final int pos, O |
132 | 134 | return docCommentContent_; |
133 | 135 | } |
134 | 136 |
|
| 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 | + |
135 | 166 | @Override public int getSourcePos(int index) { |
136 | 167 | return pos + index; |
137 | 168 | } |
|
0 commit comments