String getBinaryName(TypeElement typeElement) { Name name = typeElement == null ? null : elements.getBinaryName(typeElement); return name == null ? null : name.toString(); }
@SuppressWarnings("unchecked") private int getIdFromHash(final TypeElement e) { String classBinaryName = elementUtils.getBinaryName(e).toString(); return classBinaryName.hashCode(); }
private static AnnotationMirror findAnnotationMirror(Element element, ProcessingEnvironment processingEnv, Class<? extends Annotation> annotation) { for (AnnotationMirror ann : element.getAnnotationMirrors()) { if (processingEnv.getElementUtils().getBinaryName((TypeElement) ann.getAnnotationType().asElement()). contentEquals(annotation.getName())) { return ann; } } return null; }
/** * @param element a source element * @param annotation a type of annotation * @return the instance of that annotation on the element, or null if not found */ private AnnotationMirror findAnnotationMirror(Element element, Class<? extends Annotation> annotation) { for (AnnotationMirror ann : element.getAnnotationMirrors()) { if (processingEnv.getElementUtils().getBinaryName((TypeElement) ann.getAnnotationType().asElement()). contentEquals(annotation.getName())) { return ann; } } return null; }
protected final void register(Element el, String path) { TypeElement clazz = (TypeElement)el; String impl = processingEnv.getElementUtils().getBinaryName(clazz).toString(); registerImpl(clazz, impl, path, Integer.MAX_VALUE); }
private String getName(Element e) { if (e.getKind().isClass() || e.getKind().isInterface()) { return processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString(); } else if (e.getKind() == ElementKind.PACKAGE) { return e.getSimpleName().toString(); } else { return getName(e.getEnclosingElement()) + '.' + e.getSimpleName(); } }
@SuppressWarnings("unchecked") private int getIdFromStrategy(final TypeElement e) { List<? extends AnnotationMirror> annotationMirrors = e.getAnnotationMirrors(); if (annotationMirrors == null || annotationMirrors.size() == 0) { return 0; } try { for (AnnotationMirror annotationMirror : annotationMirrors) { DeclaredType annotationType = annotationMirror.getAnnotationType(); ClassIdStrategy strategyAnn = annotationType.asElement().getAnnotation(ClassIdStrategy.class); if (strategyAnn != null) { String classBinaryName = elementUtils.getBinaryName(e).toString(); TypeElement element = (TypeElement) annotationType.asElement(); final Annotation sourceAnnotation = e.getAnnotation((Class<Annotation>) Class.forName(elementUtils.getBinaryName(element).toString())); ClassIdGenerationStrategy idGenerationStrategy = sourceAnnotation.annotationType().getAnnotation(ClassIdStrategy.class).value().newInstance(); return idGenerationStrategy.generateIdForClass(sourceAnnotation, classBinaryName); } } } catch (Exception ex) { processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error processing the class id for: "); } return 0; }
"META-INF/services/orbit/classes/" + elementUtils.getBinaryName(e) + ".yml", e); int classId = idFromStrategy == 0 ? getIdFromHash(e) : idFromStrategy; try (final PrintWriter writer = new PrintWriter(resource.openWriter())) try (final PrintWriter writer = new PrintWriter(classIdResource.openWriter())) writer.append(elementUtils.getBinaryName(e)); writer.flush(); writer.close();
String impl = processingEnv.getElementUtils().getBinaryName(clazz).toString(); String xface = processingEnv.getElementUtils().getBinaryName((TypeElement) processingEnv.getTypeUtils().asElement(type)).toString(); if (!processingEnv.getTypeUtils().isAssignable(clazz.asType(), type)) { AnnotationMirror ann = findAnnotationMirror(clazz, annotation);
ListMultimap<String, String> allMetaservices() { ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder(); for (Element element : round().getElementsAnnotatedWith(Metainf.Service.class)) { @Nullable TypeElement typeElement = validated(element); if (typeElement == null) { continue; } Set<String> interfaceNames = extractServiceInterfaceNames(typeElement); String binaryName = processing().getElementUtils().getBinaryName(typeElement).toString(); builder.putAll(binaryName, interfaceNames); } return builder.build(); }
switch (originatingElement.getKind()) { case CLASS: { String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement).toString(); if (originatingElement.getModifiers().contains(Modifier.ABSTRACT)) { throw new LayerGenerationException(clazz + " must not be abstract", originatingElement, processingEnv, annotation, annotationMethod); String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement.getEnclosingElement()).toString(); String method = originatingElement.getSimpleName().toString(); if (!originatingElement.getModifiers().contains(Modifier.STATIC)) {
throw new ProcessingException(interfaceElement, "Interface is not annotated with @MessageBundle or @MessageLogger"); qualifiedName = elements.getBinaryName(interfaceElement).toString(); final int lastDot = qualifiedName.lastIndexOf("."); if (lastDot > 0) {
/** * Returns the name of the class represented by the {@code typeElement} * @param typeElement a {@link TypeElement} * @param processingEnvironment the {@link ProcessingEnvironment} * @return A class name */ public String getClassName(TypeElement typeElement, ProcessingEnvironment processingEnvironment) { return processingEnvironment.getElementUtils().getBinaryName(typeElement).toString(); }
public String getBinaryName(TypeElement element) { return processingEnv.getElementUtils().getBinaryName(element).toString(); }
@Override public String visitDeclared(DeclaredType x, State state) { return "L" + BinaryName.toInternalName(state.elements.getBinaryName((TypeElement) x.asElement()) .toString()) + ";"; }
private String computeSimpleName(TypeElement x, State state) { // See constants in Deobfuscator String simpleName = state.elements.getBinaryName(x).toString() + "DeobfuscatorBuilder"; if (state.isClientOnly()) { simpleName += "Lite"; } simpleName = simpleName.substring(simpleName.lastIndexOf('.') + 1); return simpleName; }
private String binaryName(TypeMirror t) { Element e = processingEnv.getTypeUtils().asElement(t); if (e != null && (e.getKind().isClass() || e.getKind().isInterface())) { return processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString(); } else { return t.toString(); // fallback - might not always be right } }
private LightCycleBinder findParent(Set<String> erasedTargetNames, TypeMirror type) { if (type.getKind() == TypeKind.NONE) { return LightCycleBinder.EMPTY; } final TypeElement typeElement = (TypeElement) ((DeclaredType) type).asElement(); if (erasedTargetNames.contains(typeElement.toString())) { final String parentWithLightCycle = elementUtils.getBinaryName(typeElement).toString(); return LightCycleBinder.forParent(binderName(parentWithLightCycle)); } return findParent(erasedTargetNames, typeElement.getSuperclass()); }
@Override public int compare(TypeElement a, TypeElement b) { DeclaredType typeA = state.types.getDeclaredType(a); DeclaredType typeB = state.types.getDeclaredType(b); if (state.types.isSameType(typeA, typeB)) { return 0; } if (state.types.isSubtype(typeA, typeB)) { return -1; } if (state.types.isSubtype(typeB, typeA)) { return 1; } return state.elements.getBinaryName(a).toString().compareTo( state.elements.getBinaryName(b).toString()); } }
state.elements.getBinaryName(requestContextElement).toString(); String clientMethodDescriptor = x.asType().accept(new DescriptorBuilder(), state); String domainMethodDescriptor = null;