/** Initialize this index, assuming that it has not already been initialized. */ public void initializeIndex() { synchronized (indexStore) { if (hasBeenInitialized) { return; } hasBeenInitialized = true; indexStore.clear(); if (!initializeIndexFrom(getIndexFile())) { if (DartCoreDebug.TRACE_INDEX_STATISTICS) { logIndexStats("Clearing index after failing to read from index file"); } indexStore.clear(); if (!initializeBundledLibraries()) { if (DartCoreDebug.TRACE_INDEX_STATISTICS) { logIndexStats("Failed to initialize bundled libraries"); } return; } if (!indexUserLibraries()) { if (DartCoreDebug.TRACE_INDEX_STATISTICS) { logIndexStats("Clearing index after failing to index user libraries"); } indexStore.clear(); initializeBundledLibraries(); } } if (DartCoreDebug.TRACE_INDEX_STATISTICS) { logIndexStats("After initializing the index"); } } }
/** * Initialize this index to contain information about the bundled libraries. The index store is * expected to have been cleared before invoking this method. * * @return {@code true} if the bundled libraries were successfully indexed */ private boolean initializeBundledLibraries() { synchronized (indexStore) { hasBeenInitialized = true; if (!initializeIndexFrom(getInitialIndexFile())) { if (DartCoreDebug.TRACE_INDEX_STATISTICS) { logIndexStats("Clearing index after failing to read from initial index file"); } indexStore.clear(); if (!indexBundledLibraries()) { if (DartCoreDebug.TRACE_INDEX_STATISTICS) { logIndexStats("Clearing index after failing to index bundled libraries"); } indexStore.clear(); return false; } // TODO(brianwilkerson) Restore the following line once we figure out how to know that the // bundled libraries (and only the bundled libraries) have been indexed. // writeIndexTo(getInitialIndexFile()); } } return true; }