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; /* loaded from: com.discord-118107.apk:lombok/delombok/DocCommentIntegrator.SCL.lombok */ public class DocCommentIntegrator { private static final Pattern CONTENT_STRIPPER = Pattern.compile("^(?:\\s*\\*)?(.*?)$", 8); /* loaded from: com.discord-118107.apk:lombok/delombok/DocCommentIntegrator$CommentAttacher_8.SCL.lombok */ private static class CommentAttacher_8 { /* renamed from: lombok.delombok.DocCommentIntegrator$CommentAttacher_8$1 reason: invalid class name */ /* loaded from: com.discord-118107.apk:lombok/delombok/DocCommentIntegrator$CommentAttacher_8$1.SCL.lombok */ 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 integrate(List list, JCTree.JCCompilationUnit jCCompilationUnit) { ArrayList arrayList = new ArrayList(); CommentInfo commentInfo = null; JCTree jCTree = null; Iterator 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; } }