static Set < String > findFilesToImport ( File searchDirectory , String fileExtension , File editedFile , String fileContent ) { // Find all the files Set < String > result = new TreeSet <> ( ) ; if ( searchDirectory . exists ( ) ) { for ( File f : Utils . listAllFiles ( searchDirectory , fileExtension ) ) { if ( f . equals ( editedFile ) ) continue ; String path = Utils . computeFileRelativeLocation ( searchDirectory , f ) ; result . add ( path ) ; } } // Remove those that are already imported Pattern importPattern = Pattern . compile ( "\\b" + ParsingConstants . KEYWORD_IMPORT + "\\s+(.*)" , Pattern . CASE_INSENSITIVE ) ; Matcher m = importPattern . matcher ( fileContent ) ; while ( m . find ( ) ) { String imp = m . group ( 1 ) . trim ( ) ; if ( imp . endsWith ( ";" ) ) imp = imp . substring ( 0 , imp . length ( ) - 1 ) ; result . remove ( imp . trim ( ) ) ; } return result ; }
Finds all the files that can be imported .