| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 source_file_provider; | 5 library source_file_provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 class BazelInputProvider extends SourceFileProvider { | 382 class BazelInputProvider extends SourceFileProvider { |
| 383 final List<Uri> dirs; | 383 final List<Uri> dirs; |
| 384 | 384 |
| 385 BazelInputProvider(List<String> searchPaths) | 385 BazelInputProvider(List<String> searchPaths) |
| 386 : dirs = searchPaths.map(_resolve).toList(); | 386 : dirs = searchPaths.map(_resolve).toList(); |
| 387 | 387 |
| 388 static _resolve(String path) => currentDirectory.resolve(path); | 388 static _resolve(String path) => currentDirectory.resolve(path); |
| 389 | 389 |
| 390 @override | 390 @override |
| 391 Future readFromUri(Uri uri) async { | 391 Future readFromUri(Uri uri) async { |
| 392 var resolvedUri = uri; |
| 392 var path = uri.path; | 393 var path = uri.path; |
| 393 if (path.startsWith('/bazel-root')) { | 394 if (path.startsWith('/bazel-root')) { |
| 394 path = path.substring('/bazel-root/'.length); | 395 path = path.substring('/bazel-root/'.length); |
| 395 for (var dir in dirs) { | 396 for (var dir in dirs) { |
| 396 var file = dir.resolve(path); | 397 var file = dir.resolve(path); |
| 397 if (await new File.fromUri(file).exists()) { | 398 if (await new File.fromUri(file).exists()) { |
| 398 uri = file; | 399 resolvedUri = file; |
| 399 break; | 400 break; |
| 400 } | 401 } |
| 401 } | 402 } |
| 402 } | 403 } |
| 403 return readUtf8BytesFromUri(uri); | 404 var result = await readUtf8BytesFromUri(resolvedUri); |
| 405 sourceFiles[uri] = sourceFiles[resolvedUri]; |
| 406 return result; |
| 404 } | 407 } |
| 405 } | 408 } |
| OLD | NEW |