private String getQualifiedName(Element element) { if (element instanceof QualifiedNameable) { return ((QualifiedNameable) element).getQualifiedName().toString(); } return element.toString(); }
public static boolean isPublic(Element interfaze) { QualifiedNameable qualifiedNameable = (QualifiedNameable) interfaze; return qualifiedNameable.getModifiers().contains(Modifier.PUBLIC); } }
public static String classNameFromInterface(Element interfaze) { QualifiedNameable qualifiedNameable = (QualifiedNameable) interfaze; String[] split = qualifiedNameable.getQualifiedName().toString().split("\\."); return split[split.length - 1]; // last part of qualified name is simple name }
@Override public Name getBinaryName(TypeElement type) { if (type instanceof QualifiedNameable) { QualifiedNameable qn = type; return qn.getQualifiedName(); } else { throw new IllegalArgumentException(type+" not QualifiedNameable"); } }
private String getQualifiedName(Element element) { if (element instanceof QualifiedNameable) { return ((QualifiedNameable) element).getQualifiedName().toString(); } return element.toString(); }
public static String packageNameFromInterface(Element interfaze) { QualifiedNameable qualifiedNameable = (QualifiedNameable) interfaze; String[] split = qualifiedNameable.getQualifiedName().toString().split("\\."); StringBuilder packageName = new StringBuilder(); for (int i = 0; i < split.length - 1; i++) { packageName.append(split[i]); if (i < split.length - 2) { packageName.append("."); } } return packageName.toString(); }
public static String getPackage(Element element) { if (element instanceof Symbol.ClassSymbol) { return ((Symbol.ClassSymbol) element).owner.toString(); } else { if (element instanceof QualifiedNameable) { String qualifiedName = ((QualifiedNameable) element).getQualifiedName().toString(); return qualifiedName.substring(0, qualifiedName.lastIndexOf(".")); } } return element.getSimpleName().toString(); }
private static boolean isValidAnnotation(AnnotationMirror am, ProcessorPrinter pp) { Element e1 = am.getAnnotationType().asElement(); Element e1_enclosing = e1.getEnclosingElement(); if (!(e1_enclosing instanceof QualifiedNameable)) { pp.error(TAG, "isValidAnnotation", " annotation element not instanceof QualifiedNameable)"); return false; } if (!TARGET_PACKAGE.equals(((QualifiedNameable) e1_enclosing).getQualifiedName().toString())) { return false; } return true; }
/** * Returns the qualified name of the annotation type of the given annotation mirror. */ @Pure public static @Nonnull String getQualifiedName(@Nonnull AnnotationMirror annotationMirror) { return ((QualifiedNameable) annotationMirror.getAnnotationType().asElement()).getQualifiedName().toString(); }
private static boolean isValidAnnotation(AnnotationMirror am, ProcessorPrinter pp) { Element e1 = am.getAnnotationType().asElement(); Element e1_enclosing = e1.getEnclosingElement(); if (!(e1_enclosing instanceof QualifiedNameable)) { pp.error(TAG, "isValidAnnotation", " annotation element not instanceof QualifiedNameable)"); return false; } if (!TARGET_PACKAGE.equals(((QualifiedNameable) e1_enclosing).getQualifiedName().toString())) { return false; } return true; }
@Pure @Override public @Nonnull String visitDeclared(@Nonnull DeclaredType type, @Nullable Void none) { return ((QualifiedNameable) type.asElement()).getQualifiedName().toString(); }
@Override public TypeName visitDeclared(DeclaredType declaredType, Void parameter) { final Element el = declaredType.asElement(); final String simpleName = el.getSimpleName().toString(); final String qualifiedName = el instanceof QualifiedNameable ? ((QualifiedNameable) el).getQualifiedName().toString() : simpleName; final TypeName[] generics = declaredType.getTypeArguments().stream() .map(generic -> _visit(generic, parameter)) .toArray(TypeName[]::new); return new TypeName(simpleName, qualifiedName, generics); }
static <T extends Annotation> AnnotationWrapper<T> get(AnnotatedConstruct element, Class<T> annotationClass) { checkNotNull(element, "element"); checkNotNull(annotationClass, "annotationClass"); final T annotation = element.getAnnotation(annotationClass); final String name = annotationClass.getName(); for (AnnotationMirror mirror : element.getAnnotationMirrors()) { if (((QualifiedNameable) mirror.getAnnotationType().asElement()).getQualifiedName().contentEquals(name)) { return new AnnotationWrapper<>(annotation, mirror); } } throw new IllegalArgumentException("Annotation " + annotation + " not found in " + element); }
/** * Returns the project name based on the common prefix of the packages in the given round environment. */ @Pure protected @Nonnull String getProjectName(@Nonnull RoundEnvironment roundEnvironment) { final @Nonnull Set<@Nonnull ? extends Element> rootElements = roundEnvironment.getRootElements(); final @Nonnull List<@Nonnull String> qualifiedTypeNames = new ArrayList<>(rootElements.size()); for (@Nonnull Element rootElement : rootElements) { if (rootElement.getKind().isClass() || rootElement.getKind().isInterface()) { qualifiedTypeNames.add(((QualifiedNameable) rootElement).getQualifiedName().toString()); } } final @Nonnull String longestCommonPrefixWithDot = Strings.longestCommonPrefix(qualifiedTypeNames.toArray(new String[qualifiedTypeNames.size()])); return longestCommonPrefixWithDot.contains(".") ? longestCommonPrefixWithDot.substring(0, longestCommonPrefixWithDot.lastIndexOf('.')) : longestCommonPrefixWithDot; }
@Override public Element getEnclosingElement() { return ElementOverlay.this.resolve(ast, elements, ((QualifiedNameable/*XXX*/) delegateTo.getEnclosingElement()).getQualifiedName().toString()); }
public static DomObjectSpec createFrom(Element element) { WeexDomObject annotation = element.getAnnotation(WeexDomObject.class); DomObjectSpec spec = new DomObjectSpec(); spec.type = annotation.type(); spec.canOverrideExisting = annotation.canOverrideExistingDomObject(); if (element instanceof QualifiedNameable) { spec.domObjectClass = ((QualifiedNameable) element).getQualifiedName().toString(); } else { spec.domObjectClass = element.getSimpleName().toString(); } return spec; } }
this.typeName = ((QualifiedNameable) typeElement).getQualifiedName(); this.shortTypeName = typeElement.getSimpleName().toString(); this.name = parent.getSimpleName().toString();
private void serialize( Path root, DsvConfiguration configuration, Collection<MethodPartition> partitions, Function<ExecutableElement,QualifiedNameable> keyFunction ) { partitions.forEach( partition -> { String fileSuffix = partition.getFileSuffix(); partition.getMethods().stream().collect( Collectors.groupingBy( keyFunction ) ).entrySet().forEach( kv -> { Either<DsvExportError,List<String>> headerParsingResult = fieldExporter.exportHeaders( configuration.getFieldDelimiter(), configuration.getRawHeaders() ); headerParsingResult.consume( messagePrinter::print, ( headers ) -> { File file = new File( root.toFile(), String.format( "%s%s.csv", kv.getKey().getQualifiedName(), fileSuffix ) ); serializeWithHeaders( file, configuration, kv.getValue(), headers ); } ); } ); } ); }
|| !((QualifiedNameable) myself).getQualifiedName().contentEquals(clazz);
private String fqnFor(Tree t) { Element el = ASTService.getElementImpl(t); if (el != null) { if (el.getKind().isClass() || el.getKind().isInterface() || el.getKind() == ElementKind.PACKAGE) { return ((QualifiedNameable) el).getQualifiedName().toString(); } else { Logger.getLogger(ElementOverlay.class.getName()).log(Level.SEVERE, "Not a QualifiedNameable: {0}", el); return null; } } else if (t instanceof QualIdentTree) { return ((QualIdentTree) t).getFQN(); } else if (t.getKind() == Kind.PARAMETERIZED_TYPE) { return fqnFor(((ParameterizedTypeTree) t).getType()); } else { Logger.getLogger(ElementOverlay.class.getName()).log(Level.FINE, "No element and no QualIdent"); return null; } }