/** * Return the revision number of this SDK, or {@code "0"} if the revision number cannot be * discovered. * * @return the revision number of this SDK */ @Override public String getSdkVersion() { synchronized (this) { if (sdkVersion == null) { sdkVersion = DEFAULT_VERSION; File revisionFile = new File(sdkDirectory, VERSION_FILE_NAME); try { String revision = FileUtilities.getContents(revisionFile); if (revision != null) { sdkVersion = revision.trim(); } } catch (IOException exception) { // Fall through to return the default. } } } return sdkVersion; }
/** * Read all of the configuration files to initialize the library maps. * * @param useDart2jsPaths {@code true} if the dart2js path should be used when it is available * @return the initialized library map */ protected LibraryMap initialLibraryMap(boolean useDart2jsPaths) { File librariesFile = new File( new File( new File(new File(getLibraryDirectory(), INTERNAL_DIR), SDK_LIB_METADATA_DIR), SDK_LIB_METADATA_LIB_DIR), LIBRARIES_FILE); if (!librariesFile.exists()) { // Fall back to pre SDK reorg location. librariesFile = getLegacyLibrariesFile(); } try { String contents = FileUtilities.getContents(librariesFile); return new SdkLibrariesReader(useDart2jsPaths).readFromFile(librariesFile, contents); } catch (Exception exception) { AnalysisEngine.getInstance() .getLogger() .logError( "Could not initialize the library map from " + librariesFile.getAbsolutePath(), exception); return new LibraryMap(); } }