anchor.diff:   * The resulting AST must have everything resolved that would have been resolved
    * by a [DirectiveElementBuilder].
    */
  -class DirectiveResolver extends SimpleAstVisitor {
  -  CompilationUnitElementImpl _enclosingUnit;
  -
  +class DirectiveResolver extends SimpleAstVisitor with ExistingElementResolver {
     @override
     void visitCompilationUnit(CompilationUnit node) {
       _enclosingUnit = node.element;
  
positive.code:    * compilation unit has been resolved, this set should be empty.
     */
    Set<Element> _expectedElements;
  
    /**
     * The compilation unit containing the AST nodes being visited.
     */
    CompilationUnitElementImpl _enclosingUnit;
  
    /**
     * The function type alias containing the AST nodes being visited, or `null`
  
negative.code:     getter.type = new FunctionTypeImpl(getter);
      field.getter = getter;
      return getter;
    }
  }
  
  /**
   * A mixin for classes that use an existing element model to resolve a portion
   * of an AST structure.
   */
  class ExistingElementResolver {
    /**
     * The compilation unit containing the AST nodes being visited.
     */
    CompilationUnitElementImpl _enclosingUnit;
  
    /**
     * Throw an [ElementMismatchException] to report that the element model and the
     * AST do not match. The [message] will have the path to the given [node]
     * appended to it.
     */
    void _mismatch(String message, AstNode node) {
      StringBuffer buffer = new StringBuffer();
      buffer.write('Mismatch in ');
      buffer.write(runtimeType);
      buffer.write(' while resolving ');
      buffer.writeln(_enclosingUnit?.source?.fullName);
      buffer.writeln(message);
      buffer.write('Path to root:');
      String separator = ' ';
      AstNode parent = node;
      while (parent != null) {
        buffer.write(separator);
        buffer.write(parent.runtimeType.toString());
        separator = ', ';
        parent = parent.parent;
      }
      throw new ElementMismatchException(buffer.toString());
    }
  }
  
  