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. Two Files are considered equal iff they have the same canonicalFile.-
Method Summary
Modifier and TypeMethodDescriptionGets theSourceFileobject corresponding to the canonical form of the givenFile.Returns the set consisting of all filenames ofFiles controlled by this indexer.intGet the number of distinct source files managed by this indexer.Iffile(canonicalized) is already managed by this indexer, gets the correspondingSourceFile, else it creates a newSourceFilewrappingFile, adds thatSourceFileto this indexer, and returns it.getSourceFile(int index) Get the source file with the given index (ID number).getSourceFilesWithName(String name) Returns an ordered list of allSourceFiles managed by this indexer that have the given file name.voidprint(PrintStream out) Prints the list ofFiles managed by this indexer, and related information, in a human-readable form.voidprintFiltered(PrintStream out, Collection<String> ignoredPrefixes) Prints the list ofFiless managed by this indexer, leaving out any file for which the path begins with a string inignoredPrefixes.
-
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
Returns an ordered list of allSourceFiles 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 allSourceFiles managed by this indexer.- Parameters:
name- a non-nullString, a file name- Returns:
- the ordered list of source files with file name
name, ornullif there are no such source files
-
getFilenames
Returns the set consisting of all filenames ofFiles 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 distinctFiles in this indexer with the same file name.- Returns:
- the set of all file names occurring in this indexers
-
getSourceFile
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
Gets theSourceFileobject corresponding to the canonical form of the givenFile. The givenfilemust be a file managed by this indexer. There is a 1-1 correspondence between the canonicalizedFiles and theSourceFiles maintained by this indexer. TheSourceFilewraps a reference to theFilewith some additional information, such as the index.- Parameters:
file- aFilethat is maintained by this indexer- Returns:
- the
SourceFilecorresponding tofile
-
getOrAdd
Iffile(canonicalized) is already managed by this indexer, gets the correspondingSourceFile, else it creates a newSourceFilewrappingFile, adds thatSourceFileto this indexer, and returns it.- Parameters:
file- a non-nullFilethat may or may not be managed by this indexer when this method is called- Returns:
- the corresponding
SourceFile
-
print
Prints the list ofFiles managed by this indexer, and related information, in a human-readable form.- Parameters:
out- thePrintStreamwhere the output shall be sent
-
printFiltered
Prints the list ofFiless managed by this indexer, leaving out any file for which the path begins with a string inignoredPrefixes. For example, ifignoredPrefixescontains "/include", then no file with path starting with "/include" will be printed.- Parameters:
out- thePrintStreamwhere the output shall be sentignoredPrefixes- a collection of prefixes specifying the files that should not be printed
-