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

Side by Side Diff: pkg/analyzer/lib/src/context/source.dart

Issue 2659333003: fix SourceFactoryImpl restoreUri (Closed)
Patch Set: merge Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/source_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.context.source; 5 library analyzer.src.context.source;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min;
8 9
9 import 'package:analyzer/exception/exception.dart'; 10 import 'package:analyzer/exception/exception.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
11 import 'package:analyzer/file_system/physical_file_system.dart'; 12 import 'package:analyzer/file_system/physical_file_system.dart';
12 import 'package:analyzer/source/package_map_resolver.dart'; 13 import 'package:analyzer/source/package_map_resolver.dart';
13 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/sdk.dart'; 15 import 'package:analyzer/src/generated/sdk.dart';
15 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
16 import 'package:analyzer/src/generated/utilities_dart.dart' as utils; 17 import 'package:analyzer/src/generated/utilities_dart.dart' as utils;
17 import 'package:analyzer/src/util/fast_uri.dart'; 18 import 'package:analyzer/src/util/fast_uri.dart';
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 197 }
197 if (sourceUri.scheme != 'file') { 198 if (sourceUri.scheme != 'file') {
198 //TODO(pquitslund): verify this works for non-file URIs. 199 //TODO(pquitslund): verify this works for non-file URIs.
199 return null; 200 return null;
200 } 201 }
201 202
202 Uri packageUri; 203 Uri packageUri;
203 _packages.asMap().forEach((String name, Uri uri) { 204 _packages.asMap().forEach((String name, Uri uri) {
204 if (packageUri == null) { 205 if (packageUri == null) {
205 if (utils.startsWith(sourceUri, uri)) { 206 if (utils.startsWith(sourceUri, uri)) {
206 packageUri = Uri.parse( 207 String relativePath = sourceUri.path
207 'package:$name/${sourceUri.path.substring(uri.path.length)}'); 208 .substring(min(uri.path.length, sourceUri.path.length));
209 packageUri = Uri.parse('package:$name/$relativePath');
208 } 210 }
209 } 211 }
210 }); 212 });
211 return packageUri; 213 return packageUri;
212 } 214 }
213 215
214 /** 216 /**
215 * Return a source object representing the URI that results from resolving 217 * Return a source object representing the URI that results from resolving
216 * the given (possibly relative) contained URI against the URI associated 218 * the given (possibly relative) contained URI against the URI associated
217 * with an existing source object, or `null` if the URI could not be resolved. 219 * with an existing source object, or `null` if the URI could not be resolved.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 for (UriResolver resolver in resolvers) { 261 for (UriResolver resolver in resolvers) {
260 Source result = resolver.resolveAbsolute(containedUri, actualUri); 262 Source result = resolver.resolveAbsolute(containedUri, actualUri);
261 if (result != null) { 263 if (result != null) {
262 return result; 264 return result;
263 } 265 }
264 } 266 }
265 return null; 267 return null;
266 }); 268 });
267 } 269 }
268 } 270 }
OLDNEW
« 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