generateForAnnotatedElement method

FutureOr<String> generateForAnnotatedElement(
  1. Element element,
  2. ConstantReader annotation,
  3. BuildStep buildStep
)

Implementation

FutureOr<String> generateForAnnotatedElement(
    Element element, ConstantReader annotation, BuildStep buildStep) {
  element as ClassElement;

  String baseUrl = annotation.peek('baseUrl')!.stringValue;

  HttpMethodParser methodParser = HttpMethodParser(
      GetParser(), DeleteParser(), PostParser(), PutParser(), PatchParser());

  code_builder.Class createdClass =
      methodParser.parse(element, baseUrl: baseUrl);

  return _dartfmt
      .format('${createdClass.accept(code_builder.DartEmitter())}');
}