anchor.diff:  import 'package:analyzer/dart/ast/ast.dart';
   import 'package:analyzer/dart/ast/standard_resolution_map.dart';
   import 'package:analyzer/dart/element/element.dart';
  +import 'package:analyzer/dart/element/type.dart';
   import 'package:analyzer/error/error.dart';
   import 'package:analyzer/file_system/file_system.dart';
   import 'package:analyzer/file_system/memory_file_system.dart';
  
positive.code:     expect(driver.hasFilesToAnalyze, isFalse);
    }
  
    test_knownFiles() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      var c = _p('/test/lib/c.dart');
  
      provider.newFile(
          a,
          r'''
  import 'b.dart';
  ''');
      provider.newFile(b, '');
      provider.newFile(c, '');
  
      driver.addFile(a);
      driver.addFile(c);
      await _waitForIdle();
  
      expect(driver.knownFiles, unorderedEquals([a, b, c]));
  
      // Remove a.dart and analyze.
      // Both a.dart and b.dart are not known now.
      driver.removeFile(a);
      await _waitForIdle();
      expect(driver.knownFiles, unorderedEquals([c]));
    }
  
    test_knownFiles_beforeAnalysis() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
  
      provider.newFile(a, '');
  
      // 'a.dart' is added, but not processed yet.
      // So, the set of known files is empty yet.
      driver.addFile(a);
      expect(driver.knownFiles, isEmpty);
  
      // Remove 'a.dart'.
      // It has been no analysis yet, so 'a.dart' is not in the file state, only
      // in 'added' files. So, it disappears when removed.
      driver.removeFile(a);
      expect(driver.knownFiles, isNot(contains(a)));
      expect(driver.knownFiles, isNot(contains(b)));
    }
  
    test_parseFile_shouldRefresh() async {
      var p = _p('/test/bin/a.dart');
  
      provider.newFile(p, 'class A {}');
      driver.addFile(p);
  
      // Get the result, so force the file reading.
      await driver.getResult(p);
  
      // Update the file.
      provider.newFile(p, 'class A2 {}');
  
      ParseResult parseResult = await driver.parseFile(p);
      var clazz = parseResult.unit.declarations[0] as ClassDeclaration;
      expect(clazz.name.name, 'A2');
    }
  
    test_part_getResult_afterLibrary() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      var c = _p('/test/lib/c.dart');
      provider.newFile(
          a,
          r'''
  library a;
  import 'b.dart';
  part 'c.dart';
  class A {}
  var c = new C();
  ''');
      provider.newFile(b, 'class B {}');
      provider.newFile(
          c,
          r'''
  part of a;
  class C {}
  var a = new A();
  var b = new B();
  ''');
  
      driver.addFile(a);
      driver.addFile(b);
      driver.addFile(c);
  
      // Process a.dart so that we know that it's a library for c.dart later.
      {
        AnalysisResult result = await driver.getResult(a);
        expect(result.errors, isEmpty);
        expect(_getTopLevelVarType(result.unit, 'c'), 'C');
      }
  
      // Now c.dart can be resolved without errors in the context of a.dart
      {
        AnalysisResult result = await driver.getResult(c);
        expect(result.errors, isEmpty);
        expect(_getTopLevelVarType(result.unit, 'a'), 'A');
        expect(_getTopLevelVarType(result.unit, 'b'), 'B');
      }
    }
  
    test_part_getResult_beforeLibrary() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      var c = _p('/test/lib/c.dart');
      provider.newFile(
          a,
          r'''
  library a;
  import 'b.dart';
  part 'c.dart';
  class A {}
  var c = new C();
  ''');
      provider.newFile(b, 'class B {}');
      provider.newFile(
          c,
          r'''
  part of a;
  class C {}
  var a = new A();
  var b = new B();
  ''');
  
      driver.addFile(a);
      driver.addFile(b);
      driver.addFile(c);
  
      // b.dart will be analyzed after a.dart is analyzed.
      // So, A and B references are resolved.
      AnalysisResult result = await driver.getResult(c);
      expect(result.errors, isEmpty);
      expect(_getTopLevelVarType(result.unit, 'a'), 'A');
      expect(_getTopLevelVarType(result.unit, 'b'), 'B');
    }
  
    test_part_getResult_noLibrary() async {
      var c = _p('/test/lib/c.dart');
      provider.newFile(
          c,
          r'''
  part of a;
  class C {}
  var a = new A();
  var b = new B();
  ''');
  
      driver.addFile(c);
  
      // There is no library which c.dart is a part of, so it has unresolved
      // A and B references.
      AnalysisResult result = await driver.getResult(c);
      expect(result.errors, isNotEmpty);
      expect(result.unit, isNotNull);
    }
  
    test_part_getResult_overlayOnly() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      contentOverlay[a] = r'''
  
negative.code:     AnalysisResult result = await driver.getResult(a);
      expect(result.errors, isEmpty);
      expect(_getTopLevelVarType(result.unit, 'b'), 'B');
    }
  
    test_knownFiles() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      var c = _p('/test/lib/c.dart');
  
      provider.newFile(
          a,
          r'''
  import 'b.dart';
  ''');
      provider.newFile(b, '');
      provider.newFile(c, '');
  
      driver.addFile(a);
      driver.addFile(c);
      await _waitForIdle();
  
      expect(driver.knownFiles, unorderedEquals([a, b, c]));
  
      // Remove a.dart and analyze.
      // Both a.dart and b.dart are not known now.
      driver.removeFile(a);
      await _waitForIdle();
      expect(driver.knownFiles, unorderedEquals([c]));
    }
  
    test_knownFiles_beforeAnalysis() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
  
      provider.newFile(a, '');
  
      // 'a.dart' is added, but not processed yet.
      // So, the set of known files is empty yet.
      driver.addFile(a);
      expect(driver.knownFiles, isEmpty);
  
      // Remove 'a.dart'.
      // It has been no analysis yet, so 'a.dart' is not in the file state, only
      // in 'added' files. So, it disappears when removed.
      driver.removeFile(a);
      expect(driver.knownFiles, isNot(contains(a)));
      expect(driver.knownFiles, isNot(contains(b)));
    }
  
    test_parseFile_shouldRefresh() async {
      var p = _p('/test/bin/a.dart');
  
      provider.newFile(p, 'class A {}');
      driver.addFile(p);
  
      // Get the result, so force the file reading.
      await driver.getResult(p);
  
      // Update the file.
      provider.newFile(p, 'class A2 {}');
  
      ParseResult parseResult = await driver.parseFile(p);
      var clazz = parseResult.unit.declarations[0] as ClassDeclaration;
      expect(clazz.name.name, 'A2');
    }
  
    test_part_getResult_afterLibrary() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      var c = _p('/test/lib/c.dart');
      provider.newFile(
          a,
          r'''
  library a;
  import 'b.dart';
  part 'c.dart';
  class A {}
  var c = new C();
  ''');
      provider.newFile(b, 'class B {}');
      provider.newFile(
          c,
          r'''
  part of a;
  class C {}
  var a = new A();
  var b = new B();
  ''');
  
      driver.addFile(a);
      driver.addFile(b);
      driver.addFile(c);
  
      // Process a.dart so that we know that it's a library for c.dart later.
      {
        AnalysisResult result = await driver.getResult(a);
        expect(result.errors, isEmpty);
        expect(_getTopLevelVarType(result.unit, 'c'), 'C');
      }
  
      // Now c.dart can be resolved without errors in the context of a.dart
      {
        AnalysisResult result = await driver.getResult(c);
        expect(result.errors, isEmpty);
        expect(_getTopLevelVarType(result.unit, 'a'), 'A');
        expect(_getTopLevelVarType(result.unit, 'b'), 'B');
      }
    }
  
    test_part_getResult_beforeLibrary() async {
      var a = _p('/test/lib/a.dart');
      var b = _p('/test/lib/b.dart');
      var c = _p('/test/lib/c.dart');
      provider.newFile(
          a,
          r'''
  library a;
  import 'b.dart';
  part 'c.dart';
  class A {}
  var c = new C();
  ''');
      provider.newFile(b, 'class B {}');
      provider.newFile(
          c,
          r'''
  part of a;
  class C {}
  var a = new A();
  var b = new B();
  ''');
  
      driver.addFile(a);
      driver.addFile(b);
      driver.addFile(c);
  
      // b.dart will be analyzed after a.dart is analyzed.
      // So, A and B references are resolved.
      AnalysisResult result = await driver.getResult(c);
      expect(result.errors, isEmpty);
      expect(_getTopLevelVarType(result.unit, 'a'), 'A');
      expect(_getTopLevelVarType(result.unit, 'b'), 'B');
    }
  
    test_part_getResult_noLibrary() async {
      var c = _p('/test/lib/c.dart');
      provider.newFile(
          c,
          r'''
  part of a;
  class C {}
  var a = new A();
  var b = new B();
  ''');
  
      driver.addFile(c);
  
      // There is no library which c.dart is a part of, so it has unresolved
      // A and B references.
      AnalysisResult result = await driver.getResult(c);
      expect(result.errors, isNotEmpty);
      expect(result.unit, isNotNull);
    }
  
    test_part_results_afterLibrary() async {
  