private void loadFileRecursively(String path,Map<String,ThriftFileElement> loadedFiles) throws IOException {
  ThriftFileElement element=null;
  File dir=null;
  File file=findFirstExisting(path,null);
  if (file != null) {
    file=file.getCanonicalFile();
    if (loadedFiles.containsKey(file.getAbsolutePath())) {
      return;
    }
    dir=file.getParentFile();
    element=loadSingleFile(file.getParentFile(),file.getName());
  }
  if (element == null) {
    throw new FileNotFoundException("Failed to locate " + path + " in "+ includePaths);
  }
  loadedFiles.put(file.getAbsolutePath(),element);
  ImmutableList<IncludeElement> includes=element.includes();
  if (includes.size() > 0) {
    includePaths.addFirst(dir);
    for (    IncludeElement include : includes) {
      if (!include.isCpp()) {
        loadFileRecursively(include.path(),loadedFiles);
      }
    }
    includePaths.removeFirst();
  }
}

private void loadFileRecursively ( String path , Map < String , ThriftFileElement > loadedFiles ) throws IOException { ThriftFileElement element = null ; File dir = null ; File file = findFirstExisting ( path , null ) ; if ( file != null ) { file = file . getCanonicalFile ( ) ; if ( loadedFiles . containsKey ( file . getAbsolutePath ( ) ) ) { return ; } dir = file . getParentFile ( ) ; element = loadSingleFile ( file . getParentFile ( ) , file . getName ( ) ) ; } if ( element == null ) { throw new FileNotFoundException ( "Failed to locate " + path + " in " + includePaths ) ; } loadedFiles . put ( file . getAbsolutePath ( ) , element ) ; ImmutableList < IncludeElement > includes = element . includes ( ) ; if ( includes . size ( ) > 0 ) { includePaths . addFirst ( dir ) ; for ( IncludeElement include : includes ) { if ( ! include . isCpp ( ) ) { loadFileRecursively ( include . path ( ) , loadedFiles ) ; } } includePaths . removeFirst ( ) ; } }
loads and parses a thrift file and all files included ( both directly and transitively ) by it .
