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));
}
}