visitFieldElement method

  1. @override
void visitFieldElement(
  1. FieldElement element
)
override

This is an overrided method that help to visit each field to read its metadata

Implementation

@override
void visitFieldElement(FieldElement element) {
  var reflect = element.metadata;
  ElementAnnotation? annotation;

  if (reflect.isNotEmpty) {
    annotation = reflect.firstWhere((element) => true);
  }

  /// Here we need for each field to know whether it is and injectable field
  /// using Autowired, or using Value
  fields.add(Field(
      uri: element.source?.uri.toString() ?? '',
      name: element.name,
      type: element.type.getDisplayString(withNullability: false),
      value: (annotation?.computeConstantValue())
              .toString()
              .contains((Value).toString())
          ? annotation
              ?.computeConstantValue()
              ?.getField('name')
              ?.toStringValue()
          : null,
      injectable: reflect.isNotEmpty
          ? (annotation?.computeConstantValue()?.type ?? '')
              .toString()
              .contains((AutowiredAnnotation).toString())
          : false,
      isPublic: element.isPublic));
}