maybeApplyMacro method Null safety

  1. @override
Future<List<String>?> maybeApplyMacro(
  1. TypeChecker checker,
  2. Macro macro,
  3. Element element,
  4. Resolver resolver,
  5. StringBuffer buffer,
  6. StringBuffer libraryBuffer,
  7. String originalSource
)

Implementation

@override
Future<List<String>?> maybeApplyMacro(
    TypeChecker checker,
    Macro macro,
    analyzer.Element element,
    Resolver resolver,
    StringBuffer buffer,
    StringBuffer libraryBuffer,
    String originalSource) async {
  if (!checker.hasAnnotationOf(element)) return null;
  _checkValidMacroApplication(element, macro);
  macro = _instantiateFromMeta(macro, checker.firstAnnotationOf(element)!);
  if (macro is ClassTypeMacro && element is analyzer.ClassElement) {
    macro.visitClassType(
        AnalyzerClassType(element, originalReference: element.thisType),
        _MacroTypeBuilder(libraryBuffer, element.library));
  } else if (element is analyzer.FieldElement && macro is FieldTypeMacro) {
    throw UnimplementedError(
        'FieldTypeMacro is not implemented in this prototype');
  } else if (element is analyzer.MethodElement && macro is MethodTypeMacro) {
    macro.visitMethodType(AnalyzerMethodType(element),
        _MacroTypeBuilder(libraryBuffer, element.library));
  } else if (element is analyzer.ConstructorElement &&
      macro is ConstructorTypeMacro) {
    macro.visitConstructorType(AnalyzerConstructorType(element),
        _MacroTypeBuilder(libraryBuffer, element.library));
  } else if (element is analyzer.FunctionElement &&
      macro is FunctionTypeMacro) {
    macro.visitFunctionType(AnalyzerFunctionType(element),
        _MacroTypeBuilder(libraryBuffer, element.library));
  }
}