discord-jadx/app/src/main/java/lombok/core/LombokNode.java

193 lines
5.5 KiB
Java

package lombok.core;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import lombok.core.AST;
import lombok.core.LombokNode;
/* loaded from: com.discord-118107.apk:lombok/core/LombokNode.SCL.lombok */
public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> implements DiagnosticsReceiver {
protected final AST.Kind kind;
protected final N node;
protected LombokImmutableList<L> children;
protected L parent;
protected boolean isStructurallySignificant;
protected LombokNode(N n, List<L> list, AST.Kind kind) {
this.kind = kind;
this.node = n;
this.children = list != null ? LombokImmutableList.copyOf((Collection) list) : LombokImmutableList.of();
Iterator<L> it = this.children.iterator();
while (it.hasNext()) {
L next = it.next();
next.parent = this;
if (!next.isStructurallySignificant) {
next.isStructurallySignificant = calculateIsStructurallySignificant(n);
}
}
this.isStructurallySignificant = calculateIsStructurallySignificant(null);
}
public abstract A getAst();
public String toString() {
Object[] objArr = new Object[3];
objArr[0] = this.kind;
objArr[1] = this.node == null ? "(NULL)" : this.node.getClass();
objArr[2] = this.node == null ? "" : this.node;
return String.format("NODE %s (%s) %s", objArr);
}
public String getPackageDeclaration() {
return getAst().getPackageDeclaration();
}
public ImportList getImportList() {
return getAst().getImportList();
}
public TypeResolver getImportListAsTypeResolver() {
return getAst().getImportListAsTypeResolver();
}
protected abstract boolean calculateIsStructurallySignificant(N n);
public L getNodeFor(N n) {
return (L) getAst().get(n);
}
public N get() {
return this.node;
}
public AST.Kind getKind() {
return this.kind;
}
public abstract String getName();
public L up() {
L l = this.parent;
while (l != null && !l.isStructurallySignificant) {
l = l.parent;
}
return l;
}
/* JADX WARN: Multi-variable type inference failed */
public Collection<L> upFromAnnotationToFields() {
if (getKind() != AST.Kind.ANNOTATION) {
return Collections.emptyList();
}
LombokNode up = up();
if (up == null || up.getKind() != AST.Kind.FIELD) {
return Collections.emptyList();
}
LombokNode up2 = up.up();
if (up2 == null || up2.getKind() != AST.Kind.TYPE) {
return Collections.emptyList();
}
ArrayList arrayList = new ArrayList();
Iterator<L> it = up2.down().iterator();
while (it.hasNext()) {
L next = it.next();
if (next.getKind() == AST.Kind.FIELD && fieldContainsAnnotation(next.get(), get())) {
arrayList.add(next);
}
}
return arrayList;
}
protected abstract boolean fieldContainsAnnotation(N n, N n2);
public L directUp() {
return this.parent;
}
public LombokImmutableList<L> down() {
return this.children;
}
public int getLatestJavaSpecSupported() {
return getAst().getLatestJavaSpecSupported();
}
public int getSourceVersion() {
return getAst().getSourceVersion();
}
public L top() {
return (L) getAst().top();
}
public String getFileName() {
return getAst().getFileName();
}
public L add(N n, AST.Kind kind) {
getAst().setChanged();
L l = (L) getAst().buildTree(n, kind);
if (l == null) {
return null;
}
l.parent = this;
this.children = this.children.append(l);
return l;
}
public void rebuild() {
IdentityHashMap identityHashMap = new IdentityHashMap();
gatherAndRemoveChildren(identityHashMap);
LombokNode buildTree = getAst().buildTree(get(), this.kind);
getAst().setChanged();
getAst().replaceNewWithExistingOld(identityHashMap, buildTree);
}
private void gatherAndRemoveChildren(Map<N, L> map) {
Iterator<L> it = this.children.iterator();
while (it.hasNext()) {
it.next().gatherAndRemoveChildren(map);
}
getAst().identityDetector.remove(get());
map.put(get(), this);
this.children = LombokImmutableList.of();
getAst().getNodeMap().remove(get());
}
public void removeChild(L l) {
getAst().setChanged();
this.children = this.children.removeElement(l);
}
public boolean isStructurallySignificant() {
return this.isStructurallySignificant;
}
public abstract boolean hasAnnotation(Class<? extends Annotation> cls);
public abstract <Z extends Annotation> AnnotationValues<Z> findAnnotation(Class<Z> cls);
public abstract boolean isStatic();
public abstract boolean isFinal();
public abstract boolean isTransient();
public abstract boolean isPrimitive();
public abstract boolean isEnumMember();
public abstract boolean isEnumType();
public abstract String fieldOrMethodBaseType();
public abstract int countMethodParameters();
public abstract int getStartPos();
}