Interface FileIndexer


public interface FileIndexer
A FileIndexer keeps track of all source files opened during an invocation of ABC. It associates a unique integer ID to each file, starting from 0.
  • Method Details

    • getNumSourceFiles

      int getNumSourceFiles()
      Get the number of distinct source files managed by this indexer.
      Returns:
      the number of distinct source files seen by this indexer
    • getSourceFilesWithName

      ArrayList<SourceFile> getSourceFilesWithName(String name)
      Returns an ordered list of all SourceFiles managed by this indexer that have the given file name. The file name should not contain a path separator. The order is consistent with the order used for all SourceFiles managed by this indexer.
      Parameters:
      name - a non-null String, a file name
      Returns:
      the ordered list of source files with file name name, or null if there are no such source files
    • getFilenames

      Set<String> getFilenames()
      Returns the set consisting of all filenames of Files controlled by this indexer. Note that a file name does not include the path "leading up to" the file. In other words, a file name is the last component in the path sequence. Hence there may be multiple distinct Files in this indexer with the same file name.
      Returns:
      the set of all file names occurring in this indexers
    • getSourceFile

      SourceFile getSourceFile(int index)
      Get the source file with the given index (ID number).
      Parameters:
      index - an integer in [0,n), where n is the number of source files managed by this indexer
      Returns:
      the i-th source file
    • get

      SourceFile get(File file)
      Gets the SourceFile object corresponding to the given File . The given file must be a file managed by this indexer. There is a 1-1 correspondence between such Files and the SourceFiles maintained by this indexer. The SourceFile wraps a reference to the File with some additional information, such as the index.
      Parameters:
      file - a File that is maintained by this indexer
      Returns:
      the SourceFile corresponding to file
    • getOrAdd

      SourceFile getOrAdd(File file)
      If file is already managed by this indexer, gets the corresponding SourceFile, else it creates a new SourceFile wrapping File, adds that SourceFile to this indexer, and returns it.
      Parameters:
      file - a non-null File that may or may not be managed by this indexer when this method is called
      Returns:
      the corresponding SourceFile
    • print

      void print(PrintStream out)
      Prints the list of Files managed by this indexer, and related information, in a human-readable form.
      Parameters:
      out - the PrintStream where the output shall be sent
    • printFiltered

      void printFiltered(PrintStream out, Collection<String> ignoredPrefixes)
      Prints the list of Filess managed by this indexer, leaving out any file for which the path begins with a string in ignoredPrefixes. For example, if ignoredPrefixes contains "/include", then no file with path starting with "/include" will be printed.
      Parameters:
      out - the PrintStream where the output shall be sent
      ignoredPrefixes - a collection of prefixes specifying the files that should not be printed