/**
   * Go through all sources and check which have been removed, added or modified and taint the
   * corresponding packages.
   */
  public void checkSourceStatus(boolean check_gensrc) {
    removedSources = calculateRemovedSources();
    for (Source s : removedSources) {
      if (!s.isGenerated() || check_gensrc) {
        taintPackage(s.pkg().name(), "source " + s.name() + " was removed");
      }
    }

    addedSources = calculateAddedSources();
    for (Source s : addedSources) {
      String msg = null;
      if (isIncremental()) {
        // When building from scratch, there is no point
        // printing "was added" for every file since all files are added.
        // However for an incremental build it makes sense.
        msg = "source " + s.name() + " was added";
      }
      if (!s.isGenerated() || check_gensrc) {
        taintPackage(s.pkg().name(), msg);
      }
    }

    modifiedSources = calculateModifiedSources();
    for (Source s : modifiedSources) {
      if (!s.isGenerated() || check_gensrc) {
        taintPackage(s.pkg().name(), "source " + s.name() + " was modified");
      }
    }
  }
 /**
  * Return those files where the timestamp is newer. If a source file timestamp suddenly is older
  * than what is known about it in javac_state, then consider it modified, but print a warning!
  */
 private Set<Source> calculateModifiedSources() {
   Set<Source> modified = new HashSet<>();
   for (String src : now.sources().keySet()) {
     Source n = now.sources().get(src);
     Source t = prev.sources().get(src);
     if (prev.sources().get(src) != null) {
       if (t != null) {
         if (n.lastModified() > t.lastModified()) {
           modified.add(n);
         } else if (n.lastModified() < t.lastModified()) {
           modified.add(n);
           Log.warn("The source file " + n.name() + " timestamp has moved backwards in time.");
         }
       }
     }
   }
   return modified;
 }