/** * Loads and parses a Thrift file and all files included (both directly and * transitively) by it. * * @param path A relative or absolute path to a Thrift file. * @param loadedFiles A mapping of absolute paths to parsed Thrift files. */ private void loadFileRecursively(String path, Dictionary <String, ThriftFileElement> loadedFiles) { ThriftFileElement element = null; DirectoryInfo dir = null; FileInfo file = findFirstExisting(path, null); if (file != null) { // Resolve symlinks, redundant '.' and '..' segments. //file = new FileInfo(file.getCanonicalFile()); if (loadedFiles.ContainsKey(file.FullName)) { return; } dir = file.Directory; element = loadSingleFile(file.Directory, file.FullName); } if (element == null) { throw new FileNotFoundException( "Failed to locate " + path + " in " + includePaths); } loadedFiles.Add(file.FullName, element); ImmutableList <IncludeElement> includes = element.Includes; if (includes.Count > 0) { includePaths.Insert(0, dir.FullName); foreach (IncludeElement include in includes) { if (!include.IsCpp) { loadFileRecursively(include.Path, loadedFiles); } } includePaths.RemoveAt(0); } }
public Program(ThriftFileElement element) { _element = element; }