public static int compareByTypeHierarchy(TypeMirror t1, Set<String> t1SuperSet, TypeMirror t2, Set<String> t2SuperSet) { if (typeEquals(t1, t2)) { return 0; } if (t1SuperSet.contains(getQualifiedName(t2))) { return -1; } if (t2SuperSet.contains(getQualifiedName(t1))) { return 1; } return 0; }
public static List<String> getQualifiedSuperTypeNames(TypeElement element) { List<TypeElement> types = getSuperTypes(element); List<String> qualifiedNames = new ArrayList<>(); for (TypeElement type : types) { qualifiedNames.add(getQualifiedName(type)); } return qualifiedNames; }
public static List<String> getQualifiedSuperTypeNames(TypeElement element) { List<TypeElement> types = getSuperTypes(element); List<String> qualifiedNames = new ArrayList<>(); for (TypeElement type : types) { qualifiedNames.add(getQualifiedName(type)); } return qualifiedNames; }
private static boolean isRuntimeException(TypeMirror type) { Set<String> typeSuperSet = new HashSet<>(getQualifiedSuperTypeNames(fromTypeMirror(type))); return typeSuperSet.contains(RuntimeException.class.getCanonicalName()) || getQualifiedName(type).equals(RuntimeException.class.getCanonicalName()); }
private void parseName(TypeElement layoutElement) { parsePackageName(layoutElement); interfaceFullName = ElementUtils.getQualifiedName(layoutElement); final String nameString = layoutElement.getSimpleName().toString(); if (!nameString.endsWith("Layout")) { processor.reportError(layoutElement, "@Layout interfaces should have a name ending with -Layout"); } name = nameString.substring(0, nameString.length() - "Layout".length()); }
private static void collectSuperTypeImports(TypeElement e, Set<String> autoImportedTypes) { List<TypeElement> superTypes = getSuperTypes(e); for (TypeElement superType : superTypes) { List<TypeElement> declaredTypes = getDeclaredTypes(superType); for (TypeElement declaredType : declaredTypes) { if (!superTypes.contains(declaredType)) { autoImportedTypes.add(getQualifiedName(declaredType)); } } } }
static String getReceiverTypeFullClassName(MessageResolution message) { String receiverTypeFullClassName; try { message.receiverType().getName(); throw new AssertionError(); } catch (MirroredTypeException mte) { // This exception is always thrown: use the mirrors to inspect the class receiverTypeFullClassName = ElementUtils.getQualifiedName(mte.getTypeMirror()); } return receiverTypeFullClassName; }
private static void collectInnerTypeImports(TypeElement e, Set<String> autoImportedTypes) { autoImportedTypes.add(getQualifiedName(e)); for (TypeElement innerClass : ElementFilter.typesIn(e.getEnclosedElements())) { collectInnerTypeImports(innerClass, autoImportedTypes); } }
public static String getEnclosedQualifiedName(DeclaredType mirror) { Element e = ((TypeElement) mirror.asElement()).getEnclosingElement(); if (e.getKind() == ElementKind.PACKAGE) { return ((PackageElement) e).getQualifiedName().toString(); } else if (e.getKind().isInterface() || e.getKind().isClass()) { return getQualifiedName((TypeElement) e); } else { return null; } }
public static String getUniqueIdentifier(TypeMirror typeMirror) { if (typeMirror.getKind() == TypeKind.ARRAY) { return getUniqueIdentifier(((ArrayType) typeMirror).getComponentType()) + "[]"; } else { return getQualifiedName(typeMirror); } }
public Template getTemplate(TypeMirror templateTypeMirror, boolean invokeCallback) { String qualifiedName = ElementUtils.getQualifiedName(templateTypeMirror); Template model = models.get(qualifiedName); if (model == null && invokeCallback) { callback.callback(ElementUtils.fromTypeMirror(templateTypeMirror)); model = models.get(qualifiedName); } return model; }
private static void collectInnerTypeImports(TypeElement e, Set<String> autoImportedTypes) { autoImportedTypes.add(getQualifiedName(e)); for (TypeElement innerClass : ElementFilter.typesIn(e.getEnclosedElements())) { collectInnerTypeImports(innerClass, autoImportedTypes); } }
private static void collectSuperTypeImports(TypeElement e, Set<String> autoImportedTypes) { List<TypeElement> superTypes = getSuperTypes(e); for (TypeElement superType : superTypes) { List<TypeElement> declaredTypes = getDeclaredTypes(superType); for (TypeElement declaredType : declaredTypes) { if (!superTypes.contains(declaredType)) { autoImportedTypes.add(getQualifiedName(declaredType)); } } } }
public static String getEnclosedQualifiedName(DeclaredType mirror) { Element e = ((TypeElement) mirror.asElement()).getEnclosingElement(); if (e.getKind() == ElementKind.PACKAGE) { return ((PackageElement) e).getQualifiedName().toString(); } else if (e.getKind().isInterface() || e.getKind().isClass()) { return getQualifiedName((TypeElement) e); } else { return null; } }
public static String getUniqueIdentifier(TypeMirror typeMirror) { if (typeMirror.getKind() == TypeKind.ARRAY) { return getUniqueIdentifier(((ArrayType) typeMirror).getComponentType()) + "[]"; } else { return getQualifiedName(typeMirror); } }
@Override public void appendNode(Writer w) throws IOException { Utils.appendMessagesGeneratedByInformation(w, indent, ElementUtils.getQualifiedName(element), receiverClassName); w.append(indent); Utils.appendVisibilityModifier(w, element); w.append("abstract static class ").append(clazzName).append(" extends ").append(userClassName).append(" {\n"); appendExecuteWithTarget(w); appendSpecializations(w); appendRootNode(w); appendRootNodeFactory(w); w.append(indent).append("}\n"); }
protected InteropNodeGenerator(ProcessingEnvironment processingEnv, TypeElement element, ForeignAccessFactoryGenerator containingForeignAccessFactory) { this.processingEnv = processingEnv; this.element = element; this.containingForeignAccessFactory = containingForeignAccessFactory; this.packageName = ElementUtils.getPackageName(element); this.userClassName = ElementUtils.getQualifiedName(element); this.clazzName = Utils.getSimpleResolveClassName(element); }
@Override public void appendNode(Writer w) throws IOException { Utils.appendMessagesGeneratedByInformation(w, indent, ElementUtils.getQualifiedName(element), null); w.append(indent); Utils.appendVisibilityModifier(w, element); w.append("abstract static class ").append(clazzName).append(" extends ").append(userClassName).append(" {\n"); appendExecuteWithTarget(w); appendSpecializations(w); appendRootNode(w); appendRootNodeFactory(w); w.append(indent).append("}\n"); }
public CodeTreeBuilder cast(TypeMirror type, CodeTree content) { if (ElementUtils.isVoid(type)) { tree(content); return this; } else if (type.getKind() == TypeKind.DECLARED && ElementUtils.getQualifiedName(type).equals("java.lang.Object")) { tree(content); return this; } else { return startGroup().string("(").type(type).string(")").string(" ").tree(content).end(); } }
private CodeTree createAssumptionGuard(AssumptionExpression assumption, CodeTree assumptionValue) { CodeTree assumptionGuard = CodeTreeBuilder.createBuilder().startCall("isValid_").tree(assumptionValue).end().build(); isValidSignatures.put(ElementUtils.getQualifiedName(assumption.getExpression().getResolvedType()), assumption.getExpression().getResolvedType()); return assumptionGuard; }