private static boolean isUsingNullable(Symbol symbol) { SymbolMetadata metadata = symbol.metadata(); return NULLABLE_ANNOTATIONS.stream().anyMatch(metadata::isAnnotatedWith) || isNullableThroughNonNull(symbol); }
private List<Symbol> metaAnnotations(Set<Type> knownTypes) { List<Symbol> result = new ArrayList<>(); for (AnnotationInstance annotationInstance : annotations) { Symbol annotationSymbol = annotationInstance.symbol(); Type annotationType = annotationSymbol.type(); if (!knownTypes.contains(annotationType)) { knownTypes.add(annotationType); result.add(annotationSymbol); result.addAll(((SymbolMetadataResolve) annotationSymbol.metadata()).metaAnnotations(knownTypes)); } } return new ArrayList<>(result); }
private static void collectAutowiredFields(Tree tree, Map<Symbol, VariableTree> autowiredFields) { if (!tree.is(Tree.Kind.VARIABLE)) { return; } VariableTree variable = (VariableTree) tree; Symbol variableSymbol = variable.symbol(); if (AUTOWIRED_ANNOTATIONS.stream().anyMatch(a -> variableSymbol.metadata().isAnnotatedWith(a))) { autowiredFields.put(variableSymbol, variable); } }
private static void collectAutowiredFields(Tree tree, Map<Symbol, VariableTree> autowiredFields) { if (!tree.is(Tree.Kind.VARIABLE)) { return; } VariableTree variable = (VariableTree) tree; Symbol variableSymbol = variable.symbol(); if (AUTOWIRED_ANNOTATIONS.stream().anyMatch(a -> variableSymbol.metadata().isAnnotatedWith(a))) { autowiredFields.put(variableSymbol, variable); } }
public static boolean isAnnotatedNonNull(Symbol symbol) { if (isAnnotatedNullable(symbol)) { return false; } return isUsingNonNull(symbol) || ((SymbolMetadataResolve) symbol.metadata()).metaAnnotations().stream().anyMatch(NullableAnnotationUtils::isUsingNonNull); }
private static boolean isUsingNonNull(Symbol symbol) { if (isNullableThroughNonNull(symbol)) { return false; } SymbolMetadata metadata = symbol.metadata(); return NONNULL_ANNOTATIONS.stream().anyMatch(metadata::isAnnotatedWith) || nonNullReturnTypeAnnotation(symbol) != null || nonNullFieldAnnotation(symbol) != null; }
private static boolean isServletOrEjb(Symbol symbol) { if (SERVLET_AND_EJB_CLASSES.stream().anyMatch(symbol.type()::isSubtypeOf)) { return true; } return symbol.metadata().annotations().stream().anyMatch(annotation -> annotation.symbol().type().fullyQualifiedName().startsWith("javax.ejb.")); }
private static boolean isServletOrEjb(Symbol symbol) { if (SERVLET_AND_EJB_CLASSES.stream().anyMatch(symbol.type()::isSubtypeOf)) { return true; } return symbol.metadata().annotations().stream().anyMatch(annotation -> annotation.symbol().type().fullyQualifiedName().startsWith("javax.ejb.")); }
private static boolean isNullableThroughNonNull(Symbol symbol) { List<SymbolMetadata.AnnotationValue> valuesForAnnotation = symbol.metadata().valuesForAnnotation("javax.annotation.Nonnull"); if (valuesForAnnotation == null || valuesForAnnotation.isEmpty()) { return false; } return checkAnnotationParameter(valuesForAnnotation, "when", "MAYBE") || checkAnnotationParameter(valuesForAnnotation, "when", "UNKNOWN"); }
private static boolean isNullableThroughNonNull(Symbol symbol) { List<SymbolMetadata.AnnotationValue> valuesForAnnotation = symbol.metadata().valuesForAnnotation("javax.annotation.Nonnull"); if (valuesForAnnotation == null || valuesForAnnotation.isEmpty()) { return false; } return checkAnnotationParameter(valuesForAnnotation, "when", "MAYBE") || checkAnnotationParameter(valuesForAnnotation, "when", "UNKNOWN"); }
private static boolean isTestNameOrTemporaryFolderRule(Symbol symbol) { return symbol.metadata().isAnnotatedWith("org.junit.Rule") && CHECKED_RULE.contains(symbol.type().fullyQualifiedName()); } }
private boolean isTestMethod(Symbol method) { return method.metadata().annotations().stream().anyMatch(input -> { Type type = input.symbol().type(); return type.isUnknown() || isTestAnnotation(type); }); }
private boolean isTestMethod(Symbol method) { return method.metadata().annotations().stream().anyMatch(input -> { Type type = input.symbol().type(); return type.isUnknown() || isTestAnnotation(type); }); }
@Override public void visitNode(Tree tree) { if (!hasSemantic()) { return; } if (tree.is(Tree.Kind.METHOD)) { ((MethodTree) tree).parameters().stream() .filter(v -> v.symbol().metadata().isAnnotatedWith("org.springframework.web.bind.annotation.CookieValue")) .forEach(v -> reportIssue(v.modifiers(), MESSAGE)); } else { super.visitNode(tree); } }
@Override public void visitVariable(VariableTree tree) { visitNode(tree, tree.simpleName(), tree.symbol().metadata()); super.visitVariable(tree); }
private static boolean isTransientSerializableOrInjected(VariableTree member) { if (ModifiersUtils.hasModifier(member.modifiers(), Modifier.TRANSIENT) || (isSerializable(member.type()) && !isSubtypeOfCollectionApi(member.type().symbolType()))) { return true; } SymbolMetadata metadata = member.symbol().metadata(); return metadata.isAnnotatedWith("javax.inject.Inject") || metadata.isAnnotatedWith("javax.ejb.EJB"); }
private static boolean isTransientSerializableOrInjected(VariableTree member) { if (ModifiersUtils.hasModifier(member.modifiers(), Modifier.TRANSIENT) || (isSerializable(member.type()) && !isSubtypeOfCollectionApi(member.type().symbolType()))) { return true; } SymbolMetadata metadata = member.symbol().metadata(); return metadata.isAnnotatedWith("javax.inject.Inject") || metadata.isAnnotatedWith("javax.ejb.EJB"); }