anchor.diff:      addTearDown(backend.dispose);
   
       return backend;
  +  }
  +
  +  Future<void> _setupDartAnalyzer() async {
  +    final provider = OverlayResourceProvider(PhysicalResourceProvider.INSTANCE);
  +
  +    // Analyze example sources against the drift sources from the current
  +    // drift_dev test runner.
  +    final uri = await Isolate.packageConfig;
  +    final hostConfig =
  +        PackageConfig.parseBytes(await File.fromUri(uri!).readAsBytes(), uri);
  +    final testConfig = PackageConfig([
  +      ...hostConfig.packages,
  +      Package('a', Uri.directory('/a/'), packageUriRoot: Uri.parse('lib/')),
  +    ]);
  +
  +    // Write package config used to analyze dummy sources
  +    final configBuffer = StringBuffer();
  +    PackageConfig.writeString(testConfig, configBuffer);
  +    provider.setOverlay('/a/.dart_tool/package_config.json',
  +        content: configBuffer.toString(), modificationStamp: 1);
  +
  +    // Also put sources into the overlay:
  +    sourceContents.forEach((key, value) {
  +      if (key.scheme == 'package') {
  +        final package = uri.pathSegments.first;
  +        final path =
  +            p.url.joinAll(['/$package/lib', ...uri.pathSegments.skip(1)]);
  +
  +        provider.setOverlay(path, content: value, modificationStamp: 1);
  +      }
  +    });
  +
  +    final collection = AnalysisContextCollection(
  +      includedPaths: ['/a/'],
  +      resourceProvider: provider,
  +    );
  +
  +    _dartContext = collection.contexts.single;
  +  }
  +
  +  Future<void> ensureHasDartAnalyzer() async {
  +    if (_dartContext == null) {
  +      await _setupDartAnalyzer();
  +    }
     }
   
     @override
  
positive.code: import 'package:drift_dev/src/analysis/driver/state.dart';
  import 'package:drift_dev/src/analyzer/options.dart';
  import 'package:logging/logging.dart';
  import 'package:test/expect.dart';
  import 'package:test/scaffolding.dart';
  
  class TestBackend extends DriftBackend {
    final Map<String, String> sourceContents;
  
    late final DriftAnalysisDriver driver;
  
    TestBackend(Map<String, String> sourceContents, DriftOptions options)
        : sourceContents = {
            for (final entry in sourceContents.entries)
              AssetId.parse(entry.key).uri.toString(): entry.value,
          } {
      driver = DriftAnalysisDriver(this, options);
    }
  
negative.code:   }
  
    @override
    Future<LibraryElement> readDart(Uri uri) async {
      await ensureHasDartAnalyzer();
      final result =
          await _dartContext!.currentSession.getLibraryByUri(uri.toString());
  
      return (result as LibraryElementResult).element;
    }
  
    @override
  