diff options
author | zaaarf <zaaarf@proton.me> | 2023-04-11 23:02:20 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-04-11 23:02:20 +0200 |
commit | 5579df7c39bc6d95d23bc357bdfa1d5b75cfbc24 (patch) | |
tree | fc1be533cae90fe5daee886d6123b11f99615c03 /src/main/java | |
parent | 415f1eef8b9a564eb6c2848986865e1fc8d4a5c1 (diff) |
fix: canonical way to get raw TypeMirrors
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/ftbsc/lll/processor/tools/ASTUtils.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java b/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java index 0ada98e..498a8f0 100644 --- a/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java +++ b/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java @@ -15,6 +15,7 @@ import javax.lang.model.type.*; import javax.tools.Diagnostic; import java.lang.annotation.Annotation; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -122,7 +123,7 @@ public class ASTUtils { */ public static String internalNameFromType(TypeMirror type, ProcessingEnvironment env) { //needed to actually turn elem into a TypeVariable, find it ignoring generics - Element elem = env.getElementUtils().getTypeElement(type.toString().split("<")[0]); + Element elem = env.getTypeUtils().asElement(env.getTypeUtils().erasure(type)); StringBuilder fqnBuilder = new StringBuilder(); while(elem.getEnclosingElement() != null && elem.getEnclosingElement().getKind() != ElementKind.PACKAGE) { fqnBuilder @@ -131,7 +132,7 @@ public class ASTUtils { elem = elem.getEnclosingElement(); } return fqnBuilder - .insert(0, elem.asType().toString().split("<")[0]) + .insert(0, env.getTypeUtils().erasure(elem.asType()).toString()) .toString() .replace('.', '/'); } @@ -143,6 +144,8 @@ public class ASTUtils { * @return a {@link String} containing the relevant descriptor */ public static String descriptorFromType(TypeMirror t, ProcessingEnvironment env) { + t = env.getTypeUtils().erasure(t); //type erasure + StringBuilder desc = new StringBuilder(); //add array brackets while(t.getKind() == TypeKind.ARRAY) { |