private List < CompilerInput > getDepthFirstDependenciesOf ( CompilerInput rootInput , Set < CompilerInput > unreachedInputs , Map < String , CompilerInput > inputsByProvide ) { List < CompilerInput > orderedInputs = new ArrayList <> ( ) ; if ( ! unreachedInputs . remove ( rootInput ) ) { return orderedInputs ; } for ( String importedNamespace : rootInput . getRequiredSymbols ( ) ) { CompilerInput dependency = null ; if ( inputsByProvide . containsKey ( importedNamespace ) && unreachedInputs . contains ( inputsByProvide . get ( importedNamespace ) ) ) { dependency = inputsByProvide . get ( importedNamespace ) ; } if ( dependency != null ) { orderedInputs . addAll ( getDepthFirstDependenciesOf ( dependency , unreachedInputs , inputsByProvide ) ) ; } } orderedInputs . add ( rootInput ) ; return orderedInputs ; }
Given an input and set of unprocessed inputs return the input and it s strong dependencies by performing a recursive depth - first traversal .