2022-03-07 09:34:54 +00:00
|
|
|
package lombok.delombok;
|
|
|
|
|
|
|
|
import com.sun.tools.javac.parser.Tokens;
|
|
|
|
import com.sun.tools.javac.tree.DocCommentTable;
|
|
|
|
import com.sun.tools.javac.tree.JCTree;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import lombok.javac.CommentInfo;
|
|
|
|
import lombok.javac.Javac;
|
|
|
|
import lombok.javac.PackageName;
|
|
|
|
import lombok.javac.handlers.JavacHandlerUtil;
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/delombok/DocCommentIntegrator.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
public class DocCommentIntegrator {
|
|
|
|
private static final Pattern CONTENT_STRIPPER = Pattern.compile("^(?:\\s*\\*)?(.*?)$", 8);
|
|
|
|
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/delombok/DocCommentIntegrator$CommentAttacher_8.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
private static class CommentAttacher_8 {
|
|
|
|
|
|
|
|
/* renamed from: lombok.delombok.DocCommentIntegrator$CommentAttacher_8$1 reason: invalid class name */
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/delombok/DocCommentIntegrator$CommentAttacher_8$1.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
class AnonymousClass1 implements Tokens.Comment {
|
|
|
|
private final /* synthetic */ String val$docCommentContent_;
|
|
|
|
private final /* synthetic */ JCTree val$node;
|
|
|
|
|
|
|
|
AnonymousClass1(String str, JCTree jCTree) {
|
|
|
|
this.val$docCommentContent_ = str;
|
|
|
|
this.val$node = jCTree;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getText() {
|
|
|
|
return this.val$docCommentContent_;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSourcePos(int i) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Tokens.Comment.CommentStyle getStyle() {
|
|
|
|
return Tokens.Comment.CommentStyle.JAVADOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isDeprecated() {
|
|
|
|
return JavacHandlerUtil.nodeHasDeprecatedFlag(this.val$node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private CommentAttacher_8() {
|
|
|
|
}
|
|
|
|
|
|
|
|
static void attach(JCTree jCTree, String str, Object obj) {
|
|
|
|
((DocCommentTable) obj).putComment(jCTree, new AnonymousClass1(str, jCTree));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<CommentInfo> integrate(List<CommentInfo> list, JCTree.JCCompilationUnit jCCompilationUnit) {
|
|
|
|
ArrayList arrayList = new ArrayList();
|
|
|
|
CommentInfo commentInfo = null;
|
|
|
|
JCTree jCTree = null;
|
|
|
|
Iterator<CommentInfo> it = list.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
CommentInfo next = it.next();
|
|
|
|
if (!next.isJavadoc()) {
|
|
|
|
arrayList.add(next);
|
|
|
|
} else {
|
|
|
|
JCTree findJavadocableNodeOnOrAfter = findJavadocableNodeOnOrAfter(jCCompilationUnit, next.endPos);
|
|
|
|
if (findJavadocableNodeOnOrAfter == null) {
|
|
|
|
arrayList.add(next);
|
|
|
|
} else {
|
|
|
|
if (findJavadocableNodeOnOrAfter == jCTree) {
|
|
|
|
arrayList.add(commentInfo);
|
|
|
|
}
|
|
|
|
if (!attach(jCCompilationUnit, findJavadocableNodeOnOrAfter, next)) {
|
|
|
|
arrayList.add(next);
|
|
|
|
} else {
|
|
|
|
jCTree = findJavadocableNodeOnOrAfter;
|
|
|
|
commentInfo = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return arrayList;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean attach(JCTree.JCCompilationUnit jCCompilationUnit, JCTree jCTree, CommentInfo commentInfo) {
|
|
|
|
String str = commentInfo.content;
|
|
|
|
if (str.startsWith("/**")) {
|
|
|
|
str = str.substring(3);
|
|
|
|
}
|
|
|
|
if (str.endsWith("*/")) {
|
|
|
|
str = str.substring(0, str.length() - 2);
|
|
|
|
}
|
|
|
|
String trim = CONTENT_STRIPPER.matcher(str).replaceAll("$1").trim();
|
|
|
|
if (Javac.getDocComments(jCCompilationUnit) == null) {
|
|
|
|
Javac.initDocComments(jCCompilationUnit);
|
|
|
|
}
|
|
|
|
Object docComments = Javac.getDocComments(jCCompilationUnit);
|
|
|
|
if (docComments instanceof Map) {
|
|
|
|
((Map) docComments).put(jCTree, trim);
|
|
|
|
return true;
|
|
|
|
} else if (!Javac.instanceOfDocCommentTable(docComments)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
CommentAttacher_8.attach(jCTree, trim, docComments);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private JCTree findJavadocableNodeOnOrAfter(JCTree.JCCompilationUnit jCCompilationUnit, int i) {
|
|
|
|
JCTree packageNode = PackageName.getPackageNode(jCCompilationUnit);
|
|
|
|
if (packageNode != null && i <= packageNode.pos) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
Iterator it = jCCompilationUnit.defs.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
JCTree.JCClassDecl jCClassDecl = (JCTree) it.next();
|
|
|
|
if (((JCTree) jCClassDecl).pos < i) {
|
|
|
|
if (jCClassDecl instanceof JCTree.JCClassDecl) {
|
|
|
|
com.sun.tools.javac.util.List list = jCClassDecl.defs;
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
while (!list.tail.isEmpty()) {
|
|
|
|
list = list.tail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list.head != null && ((JCTree) list.head).pos >= i) {
|
|
|
|
it = jCClassDecl.defs.iterator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ((jCClassDecl instanceof JCTree.JCMethodDecl) || (jCClassDecl instanceof JCTree.JCClassDecl) || (jCClassDecl instanceof JCTree.JCVariableDecl)) {
|
|
|
|
return jCClassDecl;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|