subprojects/file-watching/src/main/java/org/gradle/internal/watch/registry/impl/HierarchicalFileWatcherUpdater.java
/**
     * Filters out directories whose ancestor is also among the watched directories.
     */
Filters out directories whose ancestor is also among the watched directories.
Filters out directories whose ancestor is also among the watched directories .
@VisibleForTesting
    static Set<Path> resolveHierarchiesToWatch(Set<Path> directories) {
        Set<Path> hierarchies = new HashSet<>();
        directories.stream()
            .sorted(Comparator.comparingInt(Path::getNameCount))
            .filter(path -> {
                Path parent = path;
                while (true) {
                    parent = parent.getParent();
                    if (parent == null) {
                        break;
                    }
                    if (hierarchies.contains(parent)) {
                        return false;
                    }
                }
                return true;
            })
            .forEach(hierarchies::add);
        return hierarchies;
    }
@ VisibleForTesting static Set < Path > resolveHierarchiesToWatch ( Set < Path > directories ) { Set < Path > hierarchies = new HashSet < > ( ) ; directories . stream ( ) . sorted ( Comparator . comparingInt ( Path :: getNameCount ) ) . filter ( path -> { Path parent = path ; while ( true ) { parent = parent . getParent ( ) ; if ( parent == null ) { break ; } if ( hierarchies . contains ( parent ) ) { return false ; } } return true ; } ) . forEach ( hierarchies :: add ) ; return hierarchies ; }
Filters out directories whose ancestor is also among the watched directories.
Filters out directories whose ancestor is also among the watched directories .