Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: pkg/analyzer/lib/src/generated/sdk_io.dart

Issue 1296033004: Support older SDKs in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/sdk_io.dart
diff --git a/pkg/analyzer/lib/src/generated/sdk_io.dart b/pkg/analyzer/lib/src/generated/sdk_io.dart
index d02d67ee8a7d85b4aa294cb3b342868b89e939fc..b155b9a784f0d0f9adde775b83fb4843bfb7c4f2 100644
--- a/pkg/analyzer/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer/lib/src/generated/sdk_io.dart
@@ -339,8 +339,10 @@ class DirectoryBasedDartSdk implements DartSdk {
JavaFile get pubExecutable {
if (_pubExecutable == null) {
_pubExecutable = _verifyExecutable(new JavaFile.relative(
- new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities
- .isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME));
+ new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
+ OSUtilities.isWindows()
+ ? _PUB_EXECUTABLE_NAME_WIN
+ : _PUB_EXECUTABLE_NAME));
}
return _pubExecutable;
}
@@ -397,6 +399,22 @@ class DirectoryBasedDartSdk implements DartSdk {
return _vmExecutable;
}
+ /**
+ * Determine the search order for trying to locate the [_LIBRARIES_FILE].
+ */
+ Iterable<JavaFile> get _libraryMapLocations sync* {
+ yield new JavaFile.relative(
+ new JavaFile.relative(
+ new JavaFile.relative(
+ new JavaFile.relative(libraryDirectory, _INTERNAL_DIR),
+ _SDK_LIBRARY_METADATA_DIR),
+ _SDK_LIBRARY_METADATA_LIB_DIR),
+ _LIBRARIES_FILE);
+ yield new JavaFile.relative(
+ new JavaFile.relative(libraryDirectory, _INTERNAL_DIR),
+ _LIBRARIES_FILE);
+ }
+
@override
Source fromFileUri(Uri uri) {
JavaFile file = new JavaFile.fromUri(uri);
@@ -471,23 +489,24 @@ class DirectoryBasedDartSdk implements DartSdk {
* is available. Return the initialized library map.
*/
LibraryMap initialLibraryMap(bool useDart2jsPaths) {
- JavaFile librariesFile = new JavaFile.relative(
- new JavaFile.relative(
- new JavaFile.relative(
- new JavaFile.relative(libraryDirectory, _INTERNAL_DIR),
- _SDK_LIBRARY_METADATA_DIR),
- _SDK_LIBRARY_METADATA_LIB_DIR),
- _LIBRARIES_FILE);
- try {
- String contents = librariesFile.readAsStringSync();
- return new SdkLibrariesReader(useDart2jsPaths).readFromFile(
- librariesFile, contents);
- } catch (exception, stackTrace) {
- AnalysisEngine.instance.logger.logError(
- "Could not initialize the library map from ${librariesFile.getAbsolutePath()}",
- new CaughtException(exception, stackTrace));
- return new LibraryMap();
+ List<String> searchedPaths = <String>[];
+ var lastStackTrace = null;
+ var lastException = null;
+ for (JavaFile librariesFile in _libraryMapLocations) {
+ try {
+ String contents = librariesFile.readAsStringSync();
+ return new SdkLibrariesReader(useDart2jsPaths)
+ .readFromFile(librariesFile, contents);
+ } catch (exception, stackTrace) {
+ searchedPaths.add(librariesFile.getAbsolutePath());
+ lastException = exception;
+ lastStackTrace = stackTrace;
+ }
}
+ AnalysisEngine.instance.logger.logError(
+ "Could not initialize the library map from $searchedPaths",
+ new CaughtException(lastException, lastStackTrace));
+ return new LibraryMap();
}
@override
« no previous file with comments | « no previous file | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698