@Nullable private static Tree suppressibleNode(TreePath path) { return StreamSupport.stream(path.spliterator(), false) .filter( tree -> tree instanceof MethodTree || (tree instanceof ClassTree && ((ClassTree) tree).getSimpleName().length() != 0) || tree instanceof VariableTree) .findFirst() .orElse(null); }
/** * Adapted from {@link com.google.errorprone.fixes.SuggestedFixes}. * * <p>TODO: actually use {@link * com.google.errorprone.fixes.SuggestedFixes#addSuppressWarnings(VisitorState, String)} instead */ @Nullable private static Tree suppressibleNode(@Nullable TreePath path) { if (path == null) { return null; } return StreamSupport.stream(path.spliterator(), false) .filter( tree -> tree instanceof MethodTree || (tree instanceof ClassTree && ((ClassTree) tree).getSimpleName().length() != 0) || tree instanceof VariableTree) .findFirst() .orElse(null); }
StreamSupport.stream(where.spliterator(), false) .filter(tree -> supportedWhitelistLocationKinds.contains(tree.getKind())) .filter(Predicates.not(SuggestedFixes::isAnonymousClassTree))
StreamSupport.stream(path.spliterator(), false) .filter(tree -> tree instanceof ClassTree) .map(ClassTree.class::cast)
@Nullable private static Tree suppressibleNode(TreePath path) { return StreamSupport.stream(path.spliterator(), false) .filter( tree -> tree instanceof MethodTree || (tree instanceof ClassTree && ((ClassTree) tree).getSimpleName().length() != 0) || tree instanceof VariableTree) .findFirst() .orElse(null); }
StreamSupport.stream(where.spliterator(), false) .filter(tree -> supportedWhitelistLocationKinds.contains(tree.getKind())) .filter(Predicates.not(SuggestedFixes::isAnonymousClassTree))
StreamSupport.stream(path.spliterator(), false) .filter(tree -> tree instanceof ClassTree) .map(ClassTree.class::cast)