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

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

Issue 428303004: Breaking changes in 'analyzer' package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename Source.resolveRelative to resolveRelativeUri, soften version constraints Created 6 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 | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | pkg/analyzer/lib/src/generated/source.dart » ('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 c0b353dde4cc8ee81a927c21c61f776bba0c0365..58146c67a92f1849b79bc365060c19f92d146a04 100644
--- a/pkg/analyzer/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer/lib/src/generated/sdk_io.dart
@@ -230,7 +230,38 @@ class DirectoryBasedDartSdk implements DartSdk {
}
@override
- Source fromEncoding(UriKind kind, Uri uri) => new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
+ Source fromFileUri(Uri uri) {
+ JavaFile file = new JavaFile.fromUri(uri);
+ String filePath = file.getAbsolutePath();
+ String libPath = libraryDirectory.getAbsolutePath();
+ if (!filePath.startsWith("${libPath}${JavaFile.separator}")) {
+ return null;
+ }
+ filePath = filePath.substring(libPath.length + 1);
+ for (SdkLibrary library in _libraryMap.sdkLibraries) {
+ String libraryPath = library.path;
+ if (filePath.replaceAll('\\', '/') == libraryPath) {
+ String path = library.shortName;
+ try {
+ return new FileBasedSource.con2(parseUriWithException(path), file);
+ } on URISyntaxException catch (exception) {
+ AnalysisEngine.instance.logger.logInformation2("Failed to create URI: ${path}", exception);
+ return null;
+ }
+ }
+ libraryPath = new JavaFile(libraryPath).getParent();
+ if (filePath.startsWith("${libraryPath}${JavaFile.separator}")) {
+ String path = "${library.shortName}/${filePath.substring(libraryPath.length + 1)}";
+ try {
+ return new FileBasedSource.con2(parseUriWithException(path), file);
+ } on URISyntaxException catch (exception) {
+ AnalysisEngine.instance.logger.logInformation2("Failed to create URI: ${path}", exception);
+ return null;
+ }
+ }
+ }
+ return null;
+ }
@override
AnalysisContext get context {
@@ -419,11 +450,30 @@ class DirectoryBasedDartSdk implements DartSdk {
@override
Source mapDartUri(String dartUri) {
- SdkLibrary library = getSdkLibrary(dartUri);
+ String libraryName;
+ String relativePath;
+ int index = dartUri.indexOf('/');
+ if (index >= 0) {
+ libraryName = dartUri.substring(0, index);
+ relativePath = dartUri.substring(index + 1);
+ } else {
+ libraryName = dartUri;
+ relativePath = "";
+ }
+ SdkLibrary library = getSdkLibrary(libraryName);
if (library == null) {
return null;
}
- return new FileBasedSource.con2(new JavaFile.relative(libraryDirectory, library.path), UriKind.DART_URI);
+ try {
+ JavaFile file = new JavaFile.relative(libraryDirectory, library.path);
+ if (!relativePath.isEmpty) {
+ file = file.getParentFile();
+ file = new JavaFile.relative(file, relativePath);
+ }
+ return new FileBasedSource.con2(parseUriWithException(dartUri), file);
+ } on URISyntaxException catch (exception) {
+ return null;
+ }
}
/**
@@ -531,7 +581,7 @@ class SdkLibrariesReader {
* @param libraryFileContents the contents from the library file
* @return the library map read from the given source
*/
- LibraryMap readFromFile(JavaFile file, String libraryFileContents) => readFromSource(new FileBasedSource.con2(file, UriKind.FILE_URI), libraryFileContents);
+ LibraryMap readFromFile(JavaFile file, String libraryFileContents) => readFromSource(new FileBasedSource.con1(file), libraryFileContents);
/**
* Return the library map read from the given source.
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698