LCOV - code coverage report
Current view: top level - package_resolver-1.0.2/lib/src - current_isolate_resolver.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 0 24 0.0 %
Date: 2017-10-10 20:17:03 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
       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.
       4             : 
       5             : import 'dart:async';
       6             : import 'dart:isolate';
       7             : 
       8             : import 'package:path/path.dart' as p;
       9             : 
      10             : import 'package_config_resolver.dart';
      11             : import 'package_resolver.dart';
      12             : import 'package_root_resolver.dart';
      13             : import 'sync_package_resolver.dart';
      14             : import 'utils.dart';
      15             : 
      16             : /// The package resolution strategy used by the current isolate.
      17             : class CurrentIsolateResolver implements PackageResolver {
      18             :   Future<Map<String, Uri>> get packageConfigMap async {
      19           0 :     if (_packageConfigMap != null) return _packageConfigMap;
      20             : 
      21           0 :     var url = await Isolate.packageConfig;
      22             :     if (url == null) return null;
      23             : 
      24           0 :     return await loadConfigMap(url);
      25           0 :   }
      26             :   Map<String, Uri> _packageConfigMap;
      27             : 
      28           0 :   Future<Uri> get packageConfigUri => Isolate.packageConfig;
      29             : 
      30           0 :   Future<Uri> get packageRoot => Isolate.packageRoot;
      31             : 
      32             :   Future<SyncPackageResolver> get asSync async {
      33           0 :     var root = await packageRoot;
      34           0 :     if (root != null) return new PackageRootResolver(root);
      35             : 
      36           0 :     var map = await packageConfigMap;
      37             : 
      38             :     // It's hard to imagine how there would be no package resolution strategy
      39             :     // for an Isolate that can load the package_resolver package, but it's easy
      40             :     // to handle that case so we do.
      41           0 :     if (map == null) return SyncPackageResolver.none;
      42             : 
      43           0 :     return new PackageConfigResolver(map, uri: await packageConfigUri);
      44           0 :   }
      45             : 
      46             :   Future<String> get processArgument async {
      47           0 :     var configUri = await packageConfigUri;
      48           0 :     if (configUri != null) return "--packages=$configUri";
      49             : 
      50           0 :     var root = await packageRoot;
      51           0 :     if (root != null) return "--package-root=$root";
      52             : 
      53             :     return null;
      54           0 :   }
      55             : 
      56             :   Future<Uri> resolveUri(packageUri) =>
      57           0 :       Isolate.resolvePackageUri(asPackageUri(packageUri, "packageUri"));
      58             : 
      59             :   Future<Uri> urlFor(String package, [String path]) =>
      60           0 :       Isolate.resolvePackageUri(Uri.parse("package:$package/${path ?? ''}"));
      61             : 
      62           0 :   Future<Uri> packageUriFor(url) async => (await asSync).packageUriFor(url);
      63             : 
      64             :   Future<String> packagePath(String package) async {
      65           0 :     var root = await packageRoot;
      66           0 :     if (root != null) return new PackageRootResolver(root).packagePath(package);
      67             : 
      68           0 :     return p.dirname(p.fromUri(await urlFor(package)));
      69           0 :   }
      70             : }

Generated by: LCOV version 1.13