@Override Nullness visitTypeCast(TypeCastNode node, SubNodeValues inputs) { ImmutableList<String> annotations = node.getType().getAnnotationMirrors().stream() .map(Object::toString) .collect(ImmutableList.toImmutableList()); return Nullness.fromAnnotations(annotations) .orElseGet( () -> hasPrimitiveType(node) ? NONNULL : inputs.valueOfSubNode(node.getOperand())); }
inheritedAnnotations.addAll(type.getAnnotationMirrors()); inheritedAnnotations.addAll(typeVar.getUpperBound().getAnnotationMirrors()); if (typeVar.asElement().getKind() == TYPE_PARAMETER) { Element genericElt = ((TypeParameterElement) typeVar.asElement()).getGenericElement();
public boolean isNullable() { for (AnnotationMirror annotation : mirror.getAnnotationMirrors()) { DeclaredType annotationType = annotation.getAnnotationType(); TypeElement annotationTypeElt = (TypeElement) annotationType.asElement(); if (annotationTypeElt.getQualifiedName().toString().equals(NULLABLE)) { return true; } } return false; }
public List<? extends AnnotationMirror> getAnnotationMirrors() { if (this.annotationMirrors == null) { this.annotationMirrors = ElementDecorator.decorateAnnotationMirrors(delegate.getAnnotationMirrors(), env); } return this.annotationMirrors; }
public List<? extends AnnotationMirror> getAnnotationMirrors() { if (this.annotationMirrors == null) { this.annotationMirrors = ElementDecorator.decorateAnnotationMirrors(delegate.getAnnotationMirrors(), env); } return this.annotationMirrors; }
public @Nonnull String getFieldType(@Nonnull TypeImporter typeImporter) { final @Nonnull StringBuilder returnTypeAsString = new StringBuilder(); returnTypeAsString.append(ProcessingUtility.getAnnotationsAsString(FiniteIterable.of(getType().getAnnotationMirrors()), typeImporter)); returnTypeAsString.append(typeImporter.importIfPossible(getType())); return returnTypeAsString.toString(); }
/** * Returns the annotations of the given type mirror with their values as a string. */ @Pure public static @Nonnull String getAnnotationsAsString(@Nonnull TypeMirror typeMirror, @NonCaptured @Modified @Nonnull TypeImporter typeImporter) { return getAnnotationsAsString(FiniteIterable.of(typeMirror.getAnnotationMirrors()), typeImporter); }
@Override Nullness visitTypeCast(TypeCastNode node, SubNodeValues inputs) { ImmutableList<String> annotations = node.getType().getAnnotationMirrors().stream() .map(Object::toString) .collect(ImmutableList.toImmutableList()); return Nullness.fromAnnotations(annotations) .orElseGet( () -> hasPrimitiveType(node) ? NONNULL : inputs.valueOfSubNode(node.getOperand())); }
@Pure @Override public @Nonnull FiniteIterable<@Nonnull AnnotationMirror> getAnnotations() { return super.getAnnotations().combine(FiniteIterable.of(getGetter().getElement().getReturnType().getAnnotationMirrors())); }
private static Parameter forVariableElement( VariableElement variable, TypeMirror type, Types types) { Optional<AnnotationMirror> nullable = Optional.absent(); Iterable<? extends AnnotationMirror> annotations = Iterables.concat(variable.getAnnotationMirrors(), type.getAnnotationMirrors()); for (AnnotationMirror annotation : annotations) { if (isNullable(annotation)) { nullable = Optional.of(annotation); break; } } Key key = Key.create(type, annotations, types); return new AutoValue_Parameter( type, variable.getSimpleName().toString(), key, wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), nullable)); }
private Nullness returnValueNullness(MethodInvocationNode node, @Nullable ClassAndMethod callee) { if (callee == null) { return defaultAssumption; } Optional<Nullness> declaredNullness = Nullness.fromAnnotations(callee.annotations); if (declaredNullness.isPresent()) { return declaredNullness.get(); } // Auto Value accessors are nonnull unless explicitly annotated @Nullable. if (AccessPath.isAutoValueAccessor(node.getTree())) { return NONNULL; } // If there is no nullness annotation on the callee method declaration, look for applicable // annotations inherited from elsewhere. ImmutableList<String> annotations = ImmutableList.<String>builder() .addAll(inheritedAnnotations(node.getTarget().getMethod().getReturnType())) .addAll( node.getType().getAnnotationMirrors().stream() .map(Object::toString) .collect(ImmutableList.toImmutableList())) .build(); return getInferredNullness(node, callee) .greatestLowerBound(Nullness.fromAnnotations(annotations).orElse(NULLABLE)); }
inheritedAnnotations.addAll(type.getAnnotationMirrors()); inheritedAnnotations.addAll(typeVar.getUpperBound().getAnnotationMirrors()); if (typeVar.asElement().getKind() == TYPE_PARAMETER) { Element genericElt = ((TypeParameterElement) typeVar.asElement()).getGenericElement();
t.getAnnotationMirrors().forEach(a -> scanAnnotation(owningType, method, a)); });
t.getAnnotationMirrors().forEach(a -> scanAnnotation(owningType, method, a)); });