mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 06:16:14 +00:00
[#3824] Our own 'Comment' ad hoc impl now also needs to provide an impl for getPos().
This commit is contained in:
4 files changed
+36
-1
No files matched your search
@@ -31,11 +31,13 @@ import java.util.regex.Pattern;
|
||||
|
||||
import com.sun.tools.javac.parser.Tokens.Comment;
|
||||
import com.sun.tools.javac.tree.DocCommentTable;
|
||||
import com.sun.tools.javac.tree.EndPosTable;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
import com.sun.tools.javac.tree.TreeScanner;
|
||||
|
||||
import lombok.javac.CommentInfo;
|
||||
@@ -132,6 +134,35 @@ public class DocCommentIntegrator {
|
||||
return docCommentContent_;
|
||||
}
|
||||
|
||||
@Override public DiagnosticPosition getPos() {
|
||||
return new DiagnosticPosition() {
|
||||
public JCTree getTree() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public int getStartPosition() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public int getPreferredPosition() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // We compile against very old versions of javac intentionally (to support old stuff), but this is the method for newer impls.
|
||||
public int getEndPosition(EndPosTable endPosTable) {
|
||||
int end = endPosTable == null ? 0 : endPosTable.getEndPos(node);
|
||||
if (end > pos) return end;
|
||||
return pos + docCommentContent_.length();
|
||||
}
|
||||
|
||||
public int getEndPosition(Map<JCTree, Integer> endPosTable) {
|
||||
Integer end = endPosTable.get(node);
|
||||
if (end != null && end.intValue() > pos) return end.intValue();
|
||||
return pos + docCommentContent_.length();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override public int getSourcePos(int index) {
|
||||
return pos + index;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.sun.tools.javac.tree;
|
||||
|
||||
public interface EndPosTable {
|
||||
int getEndPos(JCTree tree);
|
||||
}
|
||||
File renamed without changes.
@@ -55,7 +55,6 @@ import com.sun.tools.javac.tree.JCTree.JCIdent;
|
||||
import com.sun.tools.javac.tree.JCTree.JCImport;
|
||||
import com.sun.tools.javac.tree.JCTree.JCLiteral;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
import com.sun.tools.javac.tree.TreeInfo;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
|
||||
import lombok.core.ClassLiteral;
|
||||
|
||||
Reference in new issue
Block a user