BuildError.forAnnotation constructor
      
      BuildError.forAnnotation(
    
- ElementAnnotation context,
- String message
Creates a build error using the provided source annotation as context.
Implementation
factory BuildError.forAnnotation(
  ElementAnnotation context,
  String message,
) {
  // TOOD(b/170758395): Replace w/ patches from upstream (see pkg/source_gen).
  // https://github.com/dart-lang/sdk/issues/32454
  final annotation = context as ElementAnnotationImpl;
  final astNode = annotation.annotationAst;
  final file = SourceFile.fromString(
    annotation.source.contents.data,
    url: annotation.source.uri,
  );
  return BuildError.forSourceSpan(
    file.span(astNode.offset, astNode.offset + astNode.length),
    message,
  );
}