anchor.diff:  
   /// [Resolver] resolves imports with respect to a given environment.
   class Resolver {
  -  static const DART_PREFIX = 'dart:';
  -  static const PACKAGE_PREFIX = 'package:';
  -  static const FILE_PREFIX = 'file://';
  -
     final String packageRoot;
     final String sdkRoot;
     final List<String> failed = [];
  
positive.code: 
    /// Returns the absolute path wrt. to the given environment or null, if the
    /// import could not be resolved.
    String resolve(String uri) {
      if (uri.startsWith(DART_PREFIX)) {
        if (sdkRoot == null) {
          // No sdk-root given, do not resolve dart: URIs.
          return null;
        }
        var slashPos = uri.indexOf('/');
        var filePath;
        if (slashPos != -1) {
          var path = uri.substring(DART_PREFIX.length, slashPos);
          // Drop patch files, since we don't have their source in the compiled
          // SDK.
          if (path.endsWith('-patch')) {
            failed.add(uri);
            return null;
          }
          // Canonicalize path. For instance: _collection-dev => _collection_dev.
          path = path.replaceAll('-', '_');
          filePath = '$sdkRoot/${path}${uri.substring(slashPos, uri.length)}';
        } else {
          // Resolve 'dart:something' to be something/something.dart in the SDK.
          var lib = uri.substring(DART_PREFIX.length, uri.length);
          filePath = '$sdkRoot/$lib/${lib}.dart';
        }
        return resolveSymbolicLinks(filePath);
      }
      if (uri.startsWith(PACKAGE_PREFIX)) {
        if (packageRoot == null) {
          // No package-root given, do not resolve package: URIs.
          return null;
        }
        var path = uri.substring(PACKAGE_PREFIX.length, uri.length);
        return resolveSymbolicLinks(p.join(packageRoot, path));
      }
      if (uri.startsWith(FILE_PREFIX)) {
        return resolveSymbolicLinks(p.fromUri(Uri.parse(uri)));
      }
      // We cannot deal with anything else.
      failed.add(uri);
      return null;
    }
  
  
negative.code: 
    /// Returns the absolute path wrt. to the given environment or null, if the
    /// import could not be resolved.
    String resolve(String scriptUri) {
      var uri = Uri.parse(scriptUri);
      if (uri.scheme == 'dart') {
        // Ignore the SDK
        return null;
      }
      if (uri.scheme == 'package') {
        // TODO(cbracken) belongs in a Bazel package
        return _resolveBazelPackage(uri.pathSegments);
      }
      if (uri.scheme == 'file') {
        var runfilesPathSegment = '.runfiles/$workspacePath';
        runfilesPathSegment =
            runfilesPathSegment.replaceAll(new RegExp(r'/*$'), '/');
        var runfilesPos = uri.path.indexOf(runfilesPathSegment);
        if (runfilesPos >= 0) {
          int pathStart = runfilesPos + runfilesPathSegment.length;
          return uri.path.substring(pathStart);
        }
        return null;
      }
      if (uri.scheme == 'https' || uri.scheme == 'http') {
        return _extractHttpPath(uri);
      }
      // We cannot deal with anything else.
      failed.add('$uri');
      return null;
    }
  
    String _extractHttpPath(Uri uri) {
      int packagesPos = uri.pathSegments.indexOf('packages');
      if (packagesPos >= 0) {
        var workspacePath = uri.pathSegments.sublist(packagesPos + 1);
        return _resolveBazelPackage(workspacePath);
      }
      return uri.pathSegments.join('/');
    }
  
    String _resolveBazelPackage(List<String> pathSegments) {
      // TODO(cbracken) belongs in a Bazel package
      var packageName = pathSegments[0];
      var pathInPackage = pathSegments.sublist(1).join('/');
      var packagePath;
      if (packageName.contains('.')) {
        packagePath = packageName.replaceAll('.', '/');
      } else {
        packagePath = 'third_party/dart/$packageName';
      }
      return '$packagePath/lib/$pathInPackage';
    }
  }
  
  