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

Side by Side Diff: pkg/analyzer/lib/source/embedder.dart

Issue 1600933007: fix embedder url mapping on Windows (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/source/embedder_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.source.embedder; 5 library analyzer.source.embedder;
6 6
7 import 'dart:collection' show HashMap; 7 import 'dart:collection' show HashMap;
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 @override 200 @override
201 List<String> get uris => _librariesMap.uris; 201 List<String> get uris => _librariesMap.uris;
202 202
203 @override 203 @override
204 Source fromFileUri(Uri uri) { 204 Source fromFileUri(Uri uri) {
205 JavaFile file = new JavaFile.fromUri(uri); 205 JavaFile file = new JavaFile.fromUri(uri);
206 String filePath = file.getAbsolutePath(); 206 String filePath = file.getAbsolutePath();
207 207
208 String path; 208 String path;
209 for (SdkLibrary library in _librariesMap.sdkLibraries) { 209 for (SdkLibrary library in _librariesMap.sdkLibraries) {
210 String libraryPath = library.path; 210 String libraryPath = library.path.replaceAll('/', JavaFile.separator);
211 if (filePath == libraryPath) { 211 if (filePath == libraryPath) {
212 path = '$_DART_COLON_PREFIX${library.shortName}'; 212 path = '$_DART_COLON_PREFIX${library.shortName}';
213 break; 213 break;
214 } 214 }
215 } 215 }
216 if (path == null) { 216 if (path == null) {
217 for (SdkLibrary library in _librariesMap.sdkLibraries) { 217 for (SdkLibrary library in _librariesMap.sdkLibraries) {
218 String libraryPath = library.path; 218 String libraryPath = library.path.replaceAll('/', JavaFile.separator);
219 int index = libraryPath.lastIndexOf('/'); 219 int index = libraryPath.lastIndexOf(JavaFile.separator);
220 if (index == -1) { 220 if (index == -1) {
221 continue; 221 continue;
222 } 222 }
223 String prefix = libraryPath.substring(0, index + 1); 223 String prefix = libraryPath.substring(0, index + 1);
224 if (!filePath.startsWith(prefix)) { 224 if (!filePath.startsWith(prefix)) {
225 continue; 225 continue;
226 } 226 }
227 var relPath = filePath.substring(prefix.length); 227 var relPath = filePath
228 .substring(prefix.length).replaceAll(JavaFile.separator, '/');
228 path = '$_DART_COLON_PREFIX${library.shortName}/$relPath'; 229 path = '$_DART_COLON_PREFIX${library.shortName}/$relPath';
229 break; 230 break;
230 } 231 }
231 } 232 }
232 233
233 if (path != null) { 234 if (path != null) {
234 try { 235 try {
235 return new FileBasedSource(file, parseUriWithException(path)); 236 return new FileBasedSource(file, parseUriWithException(path));
236 } on URISyntaxException catch (exception, stackTrace) { 237 } on URISyntaxException catch (exception, stackTrace) {
237 AnalysisEngine.instance.logger.logInformation( 238 AnalysisEngine.instance.logger.logInformation(
(...skipping 22 matching lines...) Expand all
260 } 261 }
261 SdkLibrary library = getSdkLibrary(libraryName); 262 SdkLibrary library = getSdkLibrary(libraryName);
262 if (library == null) { 263 if (library == null) {
263 return null; 264 return null;
264 } 265 }
265 String srcPath; 266 String srcPath;
266 if (relativePath.isEmpty) { 267 if (relativePath.isEmpty) {
267 srcPath = library.path; 268 srcPath = library.path;
268 } else { 269 } else {
269 String libraryPath = library.path; 270 String libraryPath = library.path;
270 int index = libraryPath.lastIndexOf('/'); 271 int index = libraryPath.lastIndexOf(JavaFile.separator);
271 if (index == -1) { 272 if (index == -1) {
272 return null; 273 index = libraryPath.lastIndexOf('/');
274 if (index == -1) {
275 return null;
276 }
273 } 277 }
274 String prefix = libraryPath.substring(0, index + 1); 278 String prefix = libraryPath.substring(0, index + 1);
275 srcPath = '$prefix$relativePath'; 279 srcPath = '$prefix$relativePath';
276 } 280 }
277 String filePath = srcPath.replaceAll('/', JavaFile.separator); 281 String filePath = srcPath.replaceAll('/', JavaFile.separator);
278 try { 282 try {
279 JavaFile file = new JavaFile(filePath); 283 JavaFile file = new JavaFile(filePath);
280 return new FileBasedSource(file, parseUriWithException(dartUri)); 284 return new FileBasedSource(file, parseUriWithException(dartUri));
281 } on URISyntaxException { 285 } on URISyntaxException {
282 return null; 286 return null;
283 } 287 }
284 } 288 }
285 } 289 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/source/embedder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698