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

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

Issue 2667633004: Remove class FastUri from analyzer. (Closed)
Patch Set: 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/lib/src/dart/analysis/file_state.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 import 'dart:math' show min;
9 9
10 import 'package:analyzer/exception/exception.dart'; 10 import 'package:analyzer/exception/exception.dart';
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/file_system/physical_file_system.dart'; 12 import 'package:analyzer/file_system/physical_file_system.dart';
13 import 'package:analyzer/source/package_map_resolver.dart'; 13 import 'package:analyzer/source/package_map_resolver.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/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';
19 import 'package:package_config/packages.dart'; 18 import 'package:package_config/packages.dart';
20 19
21 /** 20 /**
22 * Instances of the class `SourceFactory` resolve possibly relative URI's 21 * Instances of the class `SourceFactory` resolve possibly relative URI's
23 * against an existing [Source]. 22 * against an existing [Source].
24 */ 23 */
25 class SourceFactoryImpl implements SourceFactory { 24 class SourceFactoryImpl implements SourceFactory {
26 @override 25 @override
27 AnalysisContext context; 26 AnalysisContext context;
28 27
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 SourceFactory clone() { 105 SourceFactory clone() {
107 SourceFactory factory = 106 SourceFactory factory =
108 new SourceFactory(resolvers, _packages, _resourceProvider); 107 new SourceFactory(resolvers, _packages, _resourceProvider);
109 factory.localSourcePredicate = _localSourcePredicate; 108 factory.localSourcePredicate = _localSourcePredicate;
110 return factory; 109 return factory;
111 } 110 }
112 111
113 @override 112 @override
114 Source forUri(String absoluteUri) { 113 Source forUri(String absoluteUri) {
115 try { 114 try {
116 Uri uri = FastUri.parse(absoluteUri); 115 Uri uri = Uri.parse(absoluteUri);
117 if (uri.isAbsolute) { 116 if (uri.isAbsolute) {
118 return _internalResolveUri(null, uri); 117 return _internalResolveUri(null, uri);
119 } 118 }
120 } catch (exception, stackTrace) { 119 } catch (exception, stackTrace) {
121 AnalysisEngine.instance.logger.logError( 120 AnalysisEngine.instance.logger.logError(
122 "Could not resolve URI: $absoluteUri", 121 "Could not resolve URI: $absoluteUri",
123 new CaughtException(exception, stackTrace)); 122 new CaughtException(exception, stackTrace));
124 } 123 }
125 return null; 124 return null;
126 } 125 }
(...skipping 24 matching lines...) Expand all
151 @override 150 @override
152 bool isLocalSource(Source source) => _localSourcePredicate.isLocal(source); 151 bool isLocalSource(Source source) => _localSourcePredicate.isLocal(source);
153 152
154 @override 153 @override
155 Source resolveUri(Source containingSource, String containedUri) { 154 Source resolveUri(Source containingSource, String containedUri) {
156 if (containedUri == null || containedUri.isEmpty) { 155 if (containedUri == null || containedUri.isEmpty) {
157 return null; 156 return null;
158 } 157 }
159 try { 158 try {
160 // Force the creation of an escaped URI to deal with spaces, etc. 159 // Force the creation of an escaped URI to deal with spaces, etc.
161 return _internalResolveUri(containingSource, FastUri.parse(containedUri)); 160 return _internalResolveUri(containingSource, Uri.parse(containedUri));
162 } on FormatException { 161 } on FormatException {
163 return null; 162 return null;
164 } catch (exception, stackTrace) { 163 } catch (exception, stackTrace) {
165 String containingFullName = 164 String containingFullName =
166 containingSource != null ? containingSource.fullName : '<null>'; 165 containingSource != null ? containingSource.fullName : '<null>';
167 AnalysisEngine.instance.logger.logInformation( 166 AnalysisEngine.instance.logger.logInformation(
168 "Could not resolve URI ($containedUri) " 167 "Could not resolve URI ($containedUri) "
169 "relative to source ($containingFullName)", 168 "relative to source ($containingFullName)",
170 new CaughtException(exception, stackTrace)); 169 new CaughtException(exception, stackTrace));
171 return null; 170 return null;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 for (UriResolver resolver in resolvers) { 260 for (UriResolver resolver in resolvers) {
262 Source result = resolver.resolveAbsolute(containedUri, actualUri); 261 Source result = resolver.resolveAbsolute(containedUri, actualUri);
263 if (result != null) { 262 if (result != null) {
264 return result; 263 return result;
265 } 264 }
266 } 265 }
267 return null; 266 return null;
268 }); 267 });
269 } 268 }
270 } 269 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/analysis/file_state.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698