Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 Future setupPackages(Uri uri) { | 385 Future setupPackages(Uri uri) { |
| 386 if (packageRoot != null) { | 386 if (packageRoot != null) { |
| 387 // Use "non-file" packages because the file version requires a [Directory] | 387 // Use "non-file" packages because the file version requires a [Directory] |
| 388 // and we can't depend on 'dart:io' classes. | 388 // and we can't depend on 'dart:io' classes. |
| 389 packages = new NonFilePackagesDirectoryPackages(packageRoot); | 389 packages = new NonFilePackagesDirectoryPackages(packageRoot); |
| 390 } else if (packageConfig != null) { | 390 } else if (packageConfig != null) { |
| 391 return callUserProvider(packageConfig).then((packageConfigContents) { | 391 return callUserProvider(packageConfig).then((packageConfigContents) { |
| 392 if (packageConfigContents is String) { | 392 if (packageConfigContents is String) { |
| 393 packageConfigContents = UTF8.encode(packageConfigContents); | 393 packageConfigContents = UTF8.encode(packageConfigContents); |
| 394 } | 394 } |
| 395 // The input provider may put a trailing 0 byte when it reads a source | |
|
Siggi Cherem (dart-lang)
2015/08/13 00:52:19
I'm surprised that we get a null terminated string
Harry Terkelsen
2015/08/13 17:02:41
I asked Johnni about it this morning. It apparentl
| |
| 396 // file, which confuses the package config parser. | |
| 397 if (packageConfigContents.length > 0 | |
| 398 && packageConfigContents.last == 0) { | |
| 399 packageConfigContents = packageConfigContents.removeLast(); | |
| 400 } | |
| 395 packages = | 401 packages = |
| 396 new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); | 402 new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); |
| 397 }); | 403 }); |
| 398 } else { | 404 } else { |
| 399 if (packagesDiscoveryProvider == null) { | 405 if (packagesDiscoveryProvider == null) { |
| 400 packages = Packages.noPackages; | 406 packages = Packages.noPackages; |
| 401 } else { | 407 } else { |
| 402 return callUserPackagesDiscovery(uri).then((p) { | 408 return callUserPackagesDiscovery(uri).then((p) { |
| 403 packages = p; | 409 packages = p; |
| 404 }); | 410 }); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 print('$message: ${tryToString(exception)}'); | 497 print('$message: ${tryToString(exception)}'); |
| 492 print(tryToString(stackTrace)); | 498 print(tryToString(stackTrace)); |
| 493 } | 499 } |
| 494 | 500 |
| 495 fromEnvironment(String name) => environment[name]; | 501 fromEnvironment(String name) => environment[name]; |
| 496 | 502 |
| 497 LibraryInfo lookupLibraryInfo(String libraryName) { | 503 LibraryInfo lookupLibraryInfo(String libraryName) { |
| 498 return library_info.LIBRARIES[libraryName]; | 504 return library_info.LIBRARIES[libraryName]; |
| 499 } | 505 } |
| 500 } | 506 } |
| OLD | NEW |