visitMethodDeclaration method
Object?
visitMethodDeclaration(
- MethodDeclaration node
)
override
Implementation
@override
Object? visitMethodDeclaration(dart_ast.MethodDeclaration node) {
final name = node.name.name;
final ignoreError = isIgnoreError(node.metadata);
final returnType = node.returnType!;
final returnTypeIdentifier =
getFirstChildOfType<dart_ast.SimpleIdentifier>(returnType)!;
final isNullable = returnType.question != null;
final returnTypeName = returnTypeIdentifier.name;
final isAsync = returnTypeName == typeFuture;
final codeComments = _codeCommentsParser(node.documentationComment?.tokens);
final genericsMaybeNull = <bool>[];
typeGenericsArgumentsMaybeNull(
(returnType as dart_ast.NamedType).typeArguments, genericsMaybeNull);
final astType = stringToAstType(returnTypeName,
generics: typeAnnotationsToTypeArguments(returnType.typeArguments),
maybeNull: isNullable,
genericsMaybeNull: genericsMaybeNull);
final parameters = node.parameters!;
final arguments =
parameters.parameters.map(formalParameterToField).toList();
if (_nativeModule != null && astType is AstCustomType && isAsync == true) {
astType.isNativeModule = true;
}
final method = Method(
name: name,
returnType: astType!,
parameters: arguments,
ignoreError: ignoreError,
isAsync: isAsync,
codeComments: codeComments);
if (_flutterModule != null) {
_flutterModule!.methods.add(method);
} else if (_nativeModule != null) {
_nativeModule!.methods.add(method);
}
node.visitChildren(this);
return null;
}