anchor.diff:    void registerNodeProcessors(
         NodeLintRegistry registry, LinterContext context) {
       var unit = context.currentUnit.unit;
  -    if (inTestMode || !inTestDir(unit)) {
  +    if (inTestMode || !context.inTestDir(unit)) {
         var visitor = _Visitor(this);
         registry.addMethodInvocation(this, visitor);
         registry.addInstanceCreationExpression(this, visitor);
         registry.addFunctionExpressionInvocation(this, visitor);
       }
  -  }
  -
  -  static bool inTestDir(CompilationUnit unit) {
  -    var path = unit.declaredElement?.source.fullName;
  -    return path != null && _testDirectories.any(path.contains);
     }
   }
   
  
positive.code: ''';
  
  class UseBuildContextSynchronously extends LintRule implements NodeLintRule {
    // todo (pq): use LinterContext.inTestDir() when available
    static final _testDirectories = [
      '${path.separator}test${path.separator}',
      '${path.separator}integration_test${path.separator}',
      '${path.separator}test_driver${path.separator}',
      '${path.separator}testing${path.separator}',
    ];
  
    /// Flag to short-circuit `inTestDir` checking when running tests.
    final bool inTestMode;
  
  
negative.code: import 'package:analyzer/dart/ast/visitor.dart';
  import 'package:analyzer/dart/element/element.dart';
  import 'package:analyzer/dart/element/type.dart';
  
  import '../analyzer.dart';
  import '../util/flutter_utils.dart';
  