/** * Initialize this index with information from the bundled libraries. * * @return <code>true</code> if the bundled libraries were successfully indexed */ private boolean indexBundledLibraries() { boolean librariesIndexed = true; long startTime = System.currentTimeMillis(); PackageLibraryManager libraryManager = PackageLibraryManagerProvider.getPackageLibraryManager(); ArrayList<String> librarySpecs = new ArrayList<String>(libraryManager.getAllLibrarySpecs()); if (librarySpecs.remove("dart:html")) { librarySpecs.add("dart:html"); } AnalysisServer analysisServer = PackageLibraryManagerProvider.getDefaultAnalysisServer(); analysisServer.reanalyze(); SavedContext savedContext = analysisServer.getSavedContext(); for (String urlSpec : librarySpecs) { try { URI libraryUri = new URI(urlSpec); File libraryFile = new File(libraryManager.resolveDartUri(libraryUri)); savedContext.resolve(libraryFile, null); } catch (URISyntaxException exception) { librariesIndexed = false; DartCore.logError( "Invalid URI returned from the system library manager: \"" + urlSpec + "\"", exception); } catch (Exception exception) { librariesIndexed = false; DartCore.logError("Could not index bundled libraries", exception); } } if (DartCoreDebug.PERF_INDEX) { long endTime = System.currentTimeMillis(); DartCore.logInformation( "Initializing the index with information from bundled libraries took " + (endTime - startTime) + " ms (" + initIndexingTime + " ms indexing)"); } return librariesIndexed; }