protected void runOperations(String directoryPath, UseCase useCase) throws IOException {
    log.info(System.lineSeparator() +
      "================================================" + System.lineSeparator() +
      "     ____     ____________________     ____" + System.lineSeparator() +
      "    /    \\   /  __|__    __|   _  \\   /    \\" + System.lineSeparator() +
      "   /  /\\  \\  \\  \\    |  |  |  |/  /  /  /\\  \\" + System.lineSeparator() +
      "  /  /__\\  \\__\\  \\   |  |  |  |\\  \\ /  /__\\  \\" + System.lineSeparator() +
      " /__/    \\__\\____/   |__|  |__| \\__\\__/    \\__\\" + System.lineSeparator() +
      "================================================");
    log.info("Starting Astra run for directory: " + directoryPath);
    AtomicLong currentFileIndex = new AtomicLong();
    AtomicLong currentPercentage = new AtomicLong();
    log.info("Counting files (this may take a few seconds)");
    Instant startTime = Instant.now();
    List<Path> javaFilesInDirectory;
    try (Stream<Path> walk = Files.walk(Paths.get(directoryPath))) {
      javaFilesInDirectory = walk
          .filter(f -> f.toFile().isFile())
          .filter(f -> f.getFileName().toString().endsWith("java"))
          .collect(Collectors.toList());
    }
    log.info(javaFilesInDirectory.size() + " .java files in directory to review");
    log.info("Applying prefilters to files in directory");
    Predicate<String> prefilteringPredicate = useCase.getPrefilteringPredicate();
    List<Path> filteredJavaFiles = javaFilesInDirectory.stream()
        .filter(f -> prefilteringPredicate.test(f.toString()))
        .collect(Collectors.toList());
    log.info(filteredJavaFiles.size() + " files remain after prefiltering");
    final Set<? extends ASTOperation> operations = useCase.getOperations();
    final String[] sources = useCase.getSources();
    final String[] classPath = useCase.getClassPath();
    for (Path f : filteredJavaFiles) {
      // TODO AstUtils.getClassFilesForSource(f.toString()); - attempt to get only relevant classpaths for a given source file?
      // TODO Naively we can multi-thread here (i.e. per file) but simple testing indicated that this slowed us down.
      applyOperationsAndSave(new File(f.toString()), operations, sources, classPath);
      long newPercentage = currentFileIndex.incrementAndGet() * 100 / filteredJavaFiles.size();
      if (newPercentage != currentPercentage.get()) {
        currentPercentage.set(newPercentage);
        logProgress(currentFileIndex.get(), currentPercentage.get(), startTime, filteredJavaFiles.size());
      }
    }
    log.info(getPrintableDuration(Duration.between(startTime, Instant.now())));
  }
protected void runOperations(String directoryPath, UseCase useCase) throws IOException {
    log.info(System.lineSeparator() +
      "================================================" + System.lineSeparator() +
      "     ____     ____________________     ____" + System.lineSeparator() +
      "    /    \\   /  __|__    __|   _  \\   /    \\" + System.lineSeparator() +
      "   /  /\\  \\  \\  \\    |  |  |  |/  /  /  /\\  \\" + System.lineSeparator() +
      "  /  /__\\  \\__\\  \\   |  |  |  |\\  \\ /  /__\\  \\" + System.lineSeparator() +
      " /__/    \\__\\____/   |__|  |__| \\__\\__/    \\__\\" + System.lineSeparator() +
      "================================================");
    log.info("Starting Astra run for directory: " + directoryPath);
    AtomicLong currentFileIndex = new AtomicLong();
    AtomicLong currentPercentage = new AtomicLong();
    log.info("Counting files (this may take a few seconds)");
    Instant startTime = Instant.now();
    List<Path> javaFilesInDirectory;
    try (Stream<Path> walk = Files.walk(Paths.get(directoryPath))) {
      javaFilesInDirectory = walk
          .filter(f -> f.toFile().isFile())
          .filter(f -> f.getFileName().toString().endsWith("java"))
          .collect(Collectors.toList());
    }
    log.info(javaFilesInDirectory.size() + " .java files in directory to review");
    log.info("Applying prefilters to files in directory");
    Predicate<String> prefilteringPredicate = useCase.getPrefilteringPredicate();
    List<Path> filteredJavaFiles = javaFilesInDirectory.stream()
        .filter(f -> prefilteringPredicate.test(f.toString()))
        .collect(Collectors.toList());
    log.info(filteredJavaFiles.size() + " files remain after prefiltering");
    final Set<? extends ASTOperation> operations = useCase.getOperations();
    final String[] sources = useCase.getSources();
    final String[] classPath = useCase.getClassPath();
    for (Path f : filteredJavaFiles) {
     
     
      applyOperationsAndSave(new File(f.toString()), operations, sources, classPath);
      long newPercentage = currentFileIndex.incrementAndGet() * 100 / filteredJavaFiles.size();
      if (newPercentage != currentPercentage.get()) {
        currentPercentage.set(newPercentage);
        logProgress(currentFileIndex.get(), currentPercentage.get(), startTime, filteredJavaFiles.size());
      }
    }
    log.info(getPrintableDuration(Duration.between(startTime, Instant.now())));
  }
protected void runoperations(string directorypath, usecase usecase) throws ioexception { log.info(system.lineseparator() + "================================================" + system.lineseparator() + " ____ ____________________ ____" + system.lineseparator() + " / \\ / __|__ __| _ \\ / \\" + system.lineseparator() + " / /\\ \\ \\ \\ | | | |/ / / /\\ \\" + system.lineseparator() + " / /__\\ \\__\\ \\ | | | |\\ \\ / /__\\ \\" + system.lineseparator() + " /__/ \\__\\____/ |__| |__| \\__\\__/ \\__\\" + system.lineseparator() + "================================================"); log.info("starting astra run for directory: " + directorypath); atomiclong currentfileindex = new atomiclong(); atomiclong currentpercentage = new atomiclong(); log.info("counting files (this may take a few seconds)"); instant starttime = instant.now(); list<path> javafilesindirectory; try (stream<path> walk = files.walk(paths.get(directorypath))) { javafilesindirectory = walk .filter(f -> f.tofile().isfile()) .filter(f -> f.getfilename().tostring().endswith("java")) .collect(collectors.tolist()); } log.info(javafilesindirectory.size() + " .java files in directory to review"); log.info("applying prefilters to files in directory"); predicate<string> prefilteringpredicate = usecase.getprefilteringpredicate(); list<path> filteredjavafiles = javafilesindirectory.stream() .filter(f -> prefilteringpredicate.test(f.tostring())) .collect(collectors.tolist()); log.info(filteredjavafiles.size() + " files remain after prefiltering"); final set<? extends astoperation> operations = usecase.getoperations(); final string[] sources = usecase.getsources(); final string[] classpath = usecase.getclasspath(); for (path f : filteredjavafiles) { applyoperationsandsave(new file(f.tostring()), operations, sources, classpath); long newpercentage = currentfileindex.incrementandget() * 100 / filteredjavafiles.size(); if (newpercentage != currentpercentage.get()) { currentpercentage.set(newpercentage); logprogress(currentfileindex.get(), currentpercentage.get(), starttime, filteredjavafiles.size()); } } log.info(getprintableduration(duration.between(starttime, instant.now()))); }