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

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

Issue 2003633002: Use FastUri instead of Uri in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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 8
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/physical_file_system.dart'; 10 import 'package:analyzer/file_system/physical_file_system.dart';
11 import 'package:analyzer/source/package_map_resolver.dart'; 11 import 'package:analyzer/source/package_map_resolver.dart';
12 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/java_core.dart'; 13 import 'package:analyzer/src/generated/java_core.dart';
14 import 'package:analyzer/src/generated/java_engine.dart'; 14 import 'package:analyzer/src/generated/java_engine.dart';
15 import 'package:analyzer/src/generated/sdk.dart'; 15 import 'package:analyzer/src/generated/sdk.dart';
16 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
17 import 'package:analyzer/src/generated/utilities_dart.dart' as utils; 17 import 'package:analyzer/src/generated/utilities_dart.dart' as utils;
18 import 'package:analyzer/src/util/fast_uri.dart';
18 import 'package:package_config/packages.dart'; 19 import 'package:package_config/packages.dart';
19 20
20 /** 21 /**
21 * Instances of the class `SourceFactory` resolve possibly relative URI's 22 * Instances of the class `SourceFactory` resolve possibly relative URI's
22 * against an existing [Source]. 23 * against an existing [Source].
23 */ 24 */
24 class SourceFactoryImpl implements SourceFactory { 25 class SourceFactoryImpl implements SourceFactory {
25 /** 26 /**
26 * The analysis context that this source factory is associated with. 27 * The analysis context that this source factory is associated with.
27 */ 28 */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 /** 131 /**
131 * Return a source object representing the given absolute URI, or `null` if 132 * Return a source object representing the given absolute URI, or `null` if
132 * the URI is not a valid URI or if it is not an absolute URI. 133 * the URI is not a valid URI or if it is not an absolute URI.
133 * 134 *
134 * @param absoluteUri the absolute URI to be resolved 135 * @param absoluteUri the absolute URI to be resolved
135 * @return a source object representing the absolute URI 136 * @return a source object representing the absolute URI
136 */ 137 */
137 @override 138 @override
138 Source forUri(String absoluteUri) { 139 Source forUri(String absoluteUri) {
139 try { 140 try {
140 Uri uri = parseUriWithException(absoluteUri); 141 Uri uri = FastUri.parse(absoluteUri);
141 if (uri.isAbsolute) { 142 if (uri.isAbsolute) {
142 return _internalResolveUri(null, uri); 143 return _internalResolveUri(null, uri);
143 } 144 }
144 } catch (exception, stackTrace) { 145 } catch (exception, stackTrace) {
145 AnalysisEngine.instance.logger.logError( 146 AnalysisEngine.instance.logger.logError(
146 "Could not resolve URI: $absoluteUri", 147 "Could not resolve URI: $absoluteUri",
147 new CaughtException(exception, stackTrace)); 148 new CaughtException(exception, stackTrace));
148 } 149 }
149 return null; 150 return null;
150 } 151 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 * if either the [containedUri] is invalid or if it cannot be resolved against 206 * if either the [containedUri] is invalid or if it cannot be resolved against
206 * the [containingSource]'s URI. 207 * the [containingSource]'s URI.
207 */ 208 */
208 @override 209 @override
209 Source resolveUri(Source containingSource, String containedUri) { 210 Source resolveUri(Source containingSource, String containedUri) {
210 if (containedUri == null || containedUri.isEmpty) { 211 if (containedUri == null || containedUri.isEmpty) {
211 return null; 212 return null;
212 } 213 }
213 try { 214 try {
214 // Force the creation of an escaped URI to deal with spaces, etc. 215 // Force the creation of an escaped URI to deal with spaces, etc.
215 return _internalResolveUri( 216 return _internalResolveUri(containingSource, FastUri.parse(containedUri));
216 containingSource, parseUriWithException(containedUri));
217 } on URISyntaxException { 217 } on URISyntaxException {
218 return null; 218 return null;
219 } catch (exception, stackTrace) { 219 } catch (exception, stackTrace) {
220 String containingFullName = 220 String containingFullName =
221 containingSource != null ? containingSource.fullName : '<null>'; 221 containingSource != null ? containingSource.fullName : '<null>';
222 AnalysisEngine.instance.logger.logInformation( 222 AnalysisEngine.instance.logger.logInformation(
223 "Could not resolve URI ($containedUri) " 223 "Could not resolve URI ($containedUri) "
224 "relative to source ($containingFullName)", 224 "relative to source ($containingFullName)",
225 new CaughtException(exception, stackTrace)); 225 new CaughtException(exception, stackTrace));
226 return null; 226 return null;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 for (UriResolver resolver in resolvers) { 322 for (UriResolver resolver in resolvers) {
323 Source result = resolver.resolveAbsolute(containedUri, actualUri); 323 Source result = resolver.resolveAbsolute(containedUri, actualUri);
324 if (result != null) { 324 if (result != null) {
325 return result; 325 return result;
326 } 326 }
327 } 327 }
328 return null; 328 return null;
329 }); 329 });
330 } 330 }
331 } 331 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/utilities_dart.dart » ('j') | pkg/analyzer/lib/src/util/fast_uri.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698