CompletionUtils { public static Map<String,RoboconfTypeBean> findAllTypes( File appDirectory ) { List<File> graphFiles = new ArrayList<> (); File graphDirectory = appDirectory; if( graphDirectory != null && graphDirectory.exists()) graphFiles = Utils.listAllFiles( graphDirectory, Constants.FILE_EXT_GRAPH ); Map<String,RoboconfTypeBean> result = new HashMap<> (); for( File f : graphFiles ) { try { FromGraphDefinition converter = new FromGraphDefinition( appDirectory, true ); Graphs g = converter.buildGraphs( f ); Collection<AbstractType> types = new ArrayList<> (); types.addAll( ComponentHelpers.findAllComponents( g )); types.addAll( g.getFacetNameToFacet().values()); for( AbstractType type : types ) { RoboconfTypeBean bean = new RoboconfTypeBean( type.getName(), converter.getTypeAnnotations().get( type.getName()), type instanceof Facet ); result.put( type.getName(), bean ); for( Map.Entry<String,String> entry : ComponentHelpers.findAllExportedVariables( type ).entrySet()) { bean.exportedVariables.put( entry.getKey(), entry.getValue()); } } } catch( Exception e ) { Logger logger = Logger.getLogger( CompletionUtils.class.getName()); Utils.logException( logger, e ); } } return result; } private  CompletionUtils(); static Set<String> findGraphFilesToImport( File appDirectory, File editedFile, String fileContent ); static Set<String> findInstancesFilesToImport( File appDirectory, File editedFile, String fileContent ); static RoboconfCompletionProposal basicProposal( String s, String lastWord, boolean trim ); static RoboconfCompletionProposal basicProposal( String s, String lastWord ); static boolean startsWith( String s, String prefix ); static Map<String,RoboconfTypeBean> findAllTypes( File appDirectory ); static String resolveStringDescription( String variableName, String defaultValue ); static Map<String,String> findAllExportedVariables( File appDirectory ); static Map<String,String> findTypeNames( File appDirectory, boolean includeFacets, boolean includeComponents ); static List<RoboconfCompletionProposal> buildProposalsFromMap( Map<String,String> candidates, String prefix ); static final String DEFAULT_VALUE; static final String SET_BY_ROBOCONF; static final String IMPORT_ALL_THE_VARIABLES; }
@Test public void testFindAllTypes_noDirectory() { Assert.assertEquals( 0, findAllTypes( new File( "whatever" )).size()); Assert.assertEquals( 0, findAllTypes( null ).size()); }