getDocumentation method

Future<String?> getDocumentation(
  1. ParameterElement parameter,
  2. BuildStep buildStep
)

Implementation

Future<String?> getDocumentation(
    ParameterElement parameter, BuildStep buildStep) async {
  if (parameter.documentationComment?.isNotEmpty == true) {
    return parameter.documentationComment;
  }

  final parameterDocumentation = await documentationOfParameter(
    parameter,
    buildStep,
  );
  if (parameterDocumentation.isNotEmpty == true) {
    return parameterDocumentation;
  }

  if (parameter.isInitializingFormal) {
    final classElement =
        parameter.enclosingElement!.enclosingElement as ClassElement;

    final field = classElement.fields
        .firstWhereOrNull((element) => element.name == parameter.name);

    if (field?.documentationComment != null) {
      return field!.documentationComment;
    }
  }
}