2022-03-02 20:59:20 +00:00
|
|
|
package lombok.core;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import lombok.core.AST;
|
2022-03-08 21:11:21 +00:00
|
|
|
/* loaded from: com.discord-117014.apk:lombok/core/TypeResolver.SCL.lombok */
|
2022-03-02 20:59:20 +00:00
|
|
|
public class TypeResolver {
|
|
|
|
private ImportList imports;
|
|
|
|
|
|
|
|
public TypeResolver(ImportList importList) {
|
|
|
|
this.imports = importList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean typeMatches(LombokNode<?, ?, ?> lombokNode, String str, String str2) {
|
|
|
|
return typeRefToFullyQualifiedName(lombokNode, TypeLibrary.createLibraryForSingleType(str), str2) != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String typeRefToFullyQualifiedName(LombokNode<?, ?, ?> lombokNode, TypeLibrary typeLibrary, String str) {
|
|
|
|
String fullyQualifiedNameForSimpleNameNoAliasing;
|
|
|
|
List<String> qualifieds = typeLibrary.toQualifieds(str);
|
|
|
|
if (qualifieds == null || qualifieds.isEmpty()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (qualifieds.contains(str)) {
|
|
|
|
return LombokInternalAliasing.processAliases(str);
|
|
|
|
}
|
|
|
|
int indexOf = str.indexOf(46);
|
|
|
|
if (indexOf == -1) {
|
|
|
|
indexOf = str.length();
|
|
|
|
}
|
|
|
|
String substring = str.substring(0, indexOf);
|
|
|
|
if (this.imports.getFullyQualifiedNameForSimpleNameNoAliasing(substring) != null) {
|
|
|
|
String str2 = String.valueOf(fullyQualifiedNameForSimpleNameNoAliasing) + str.substring(indexOf);
|
|
|
|
if (qualifieds.contains(str2)) {
|
|
|
|
return LombokInternalAliasing.processAliases(str2);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
Iterator<String> it = qualifieds.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
String next = it.next();
|
|
|
|
if (this.imports.hasStarImport(next.substring(0, (next.length() - str.length()) - 1))) {
|
|
|
|
LombokNode<?, ?, ?> lombokNode2 = lombokNode;
|
|
|
|
while (lombokNode2 != null) {
|
|
|
|
if (lombokNode2.getKind() == AST.Kind.TYPE && substring.equals(lombokNode2.getName())) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (lombokNode2.getKind() == AST.Kind.STATEMENT || lombokNode2.getKind() == AST.Kind.LOCAL) {
|
|
|
|
LombokNode<?, ?, ?> directUp = lombokNode2.directUp();
|
|
|
|
if (directUp == null) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (directUp.getKind() == AST.Kind.STATEMENT || directUp.getKind() == AST.Kind.INITIALIZER || directUp.getKind() == AST.Kind.METHOD) {
|
|
|
|
Iterator<?> it2 = directUp.down().iterator();
|
|
|
|
while (it2.hasNext()) {
|
|
|
|
LombokNode<?, ?, ?> lombokNode3 = (LombokNode) it2.next();
|
|
|
|
if (lombokNode3.getKind() != AST.Kind.TYPE || !substring.equals(lombokNode3.getName())) {
|
|
|
|
if (lombokNode3 == lombokNode2) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lombokNode2 = directUp;
|
|
|
|
} else {
|
|
|
|
if (lombokNode2.getKind() == AST.Kind.TYPE || lombokNode2.getKind() == AST.Kind.COMPILATION_UNIT) {
|
|
|
|
Iterator<?> it3 = lombokNode2.down().iterator();
|
|
|
|
while (it3.hasNext()) {
|
|
|
|
LombokNode lombokNode4 = (LombokNode) it3.next();
|
|
|
|
if (lombokNode4.getKind() == AST.Kind.TYPE && substring.equals(lombokNode4.getName())) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lombokNode2 = lombokNode2.directUp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return LombokInternalAliasing.processAliases(next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|