private static List<ProtoFile> findRelateProtoFiles(File file, Set<String> dependencyNames) throws IOException {
        LinkedList<ProtoFile> protoFiles = new LinkedList<ProtoFile>();
        ProtoFile protoFile = ProtoParser.parseUtf8(file);
        protoFiles.addFirst(protoFile);

        String parent = file.getParent();
        // parse dependency, to find all PROTO file if using import command
        List<String> dependencies = protoFile.dependencies();
        if (dependencies != null && !dependencies.isEmpty()) {
            for (String fn : dependencies) {
                if (dependencyNames.contains(fn)) {
                    continue;
                }
                File dependencyFile = new File(parent, fn);
                protoFiles.addAll(findRelateProtoFiles(dependencyFile, dependencyNames));
            }
        }
        
        List<String> publicDependencies = protoFile.publicDependencies();
        if (publicDependencies != null && !publicDependencies.isEmpty()) {
            for (String fn : publicDependencies) {
                if (dependencyNames.contains(fn)) {
                    continue;
                }
                File dependencyFile = new File(parent, fn);
                protoFiles.addAll(findRelateProtoFiles(dependencyFile, dependencyNames));
            }
        }
        
        return protoFiles;
    }
private static List < ProtoFile > findRelateProtoFiles ( File file , Set < String > dependencyNames ) throws IOException { LinkedList < ProtoFile > protoFiles = new LinkedList < ProtoFile > ( ) ; ProtoFile protoFile = ProtoParser . parseUtf8 ( file ) ; protoFiles . addFirst ( protoFile ) ; String parent = file . getParent ( ) ; List < String > dependencies = protoFile . dependencies ( ) ; if ( dependencies != null && ! dependencies . isEmpty ( ) ) { for ( String fn : dependencies ) { if ( dependencyNames . contains ( fn ) ) { continue ; } File dependencyFile = new File ( parent , fn ) ; protoFiles . addAll ( findRelateProtoFiles ( dependencyFile , dependencyNames ) ) ; } } List < String > publicDependencies = protoFile . publicDependencies ( ) ; if ( publicDependencies != null && ! publicDependencies . isEmpty ( ) ) { for ( String fn : publicDependencies ) { if ( dependencyNames . contains ( fn ) ) { continue ; } File dependencyFile = new File ( parent , fn ) ; protoFiles . addAll ( findRelateProtoFiles ( dependencyFile , dependencyNames ) ) ; } } return protoFiles ; }
Find relate proto files.

@param file the file
@param dependencyNames the dependency names
@return the list
@throws IOException Signals that an I/O exception has occurred.