reflectsFileMaker function

PartFile reflectsFileMaker(
  1. ServerServer server,
  2. String formatter(
    1. Spec
    )
)

Implementation

PartFile reflectsFileMaker(
  ServerServer server,
  String Function(Spec) formatter,
) {
  final reflects = Method(
    (p) => p
      ..name = 'reflects'
      ..lambda = true
      ..type = MethodType.getter
      ..returns = TypeReference(
        (b) => b
          ..symbol = 'Set'
          ..types.add(refer((Reflect).name)),
      )
      ..body = Block.of([
        literalSet([
          for (final reflect in server.reflects) createReflect(reflect),
        ]).statement,
      ]),
  );

  final content = formatter(reflects);

  return PartFile(
    path: ['definitions', '__reflects'],
    content: content,
  );
}