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

Unified Diff: pkg/analyzer/lib/src/context/source.dart

Issue 2659333003: fix SourceFactoryImpl restoreUri (Closed)
Patch Set: merge Created 3 years, 11 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/test/src/context/source_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/source.dart
diff --git a/pkg/analyzer/lib/src/context/source.dart b/pkg/analyzer/lib/src/context/source.dart
index 1f7c3b572d0c583ed55738fa52f35c8e16c0f6f9..1059b63657776e3d8d377f643877e947fe0171af 100644
--- a/pkg/analyzer/lib/src/context/source.dart
+++ b/pkg/analyzer/lib/src/context/source.dart
@@ -5,6 +5,7 @@
library analyzer.src.context.source;
import 'dart:collection';
+import 'dart:math' show min;
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/file_system/file_system.dart';
@@ -203,8 +204,9 @@ class SourceFactoryImpl implements SourceFactory {
_packages.asMap().forEach((String name, Uri uri) {
if (packageUri == null) {
if (utils.startsWith(sourceUri, uri)) {
- packageUri = Uri.parse(
- 'package:$name/${sourceUri.path.substring(uri.path.length)}');
+ String relativePath = sourceUri.path
+ .substring(min(uri.path.length, sourceUri.path.length));
+ packageUri = Uri.parse('package:$name/$relativePath');
}
}
});
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/source_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698