@@ -10,6 +10,7 @@ import 'package:analyzer/error/error.dart';
1010
1111import '../analyzer.dart' ;
1212import '../extensions.dart' ;
13+ import '../utils.dart' ;
1314
1415const _desc =
1516 'There should be no `Future`-returning calls in synchronous functions unless they '
@@ -63,7 +64,7 @@ class _Visitor extends SimpleAstVisitor<void> {
6364 return ;
6465 }
6566
66- _reportOnExpression ( expr);
67+ reportOnExpression (rule, expr);
6768 }
6869 }
6970
@@ -94,17 +95,6 @@ class _Visitor extends SimpleAstVisitor<void> {
9495 expr.methodName.name == 'putIfAbsent' &&
9596 _isMapClass (expr.methodName.element? .enclosingElement);
9697
97- void _reportOnExpression (Expression expr) {
98- rule.reportAtNode (switch (expr) {
99- MethodInvocation (: var methodName) => methodName,
100- InstanceCreationExpression (: var constructorName) => constructorName,
101- FunctionExpressionInvocation (: var function) => function,
102- PrefixedIdentifier (: var identifier) => identifier,
103- PropertyAccess (: var propertyName) => propertyName,
104- _ => expr,
105- });
106- }
107-
10898 void _visit (Expression expr) {
10999 if (expr.isAwaitNotRequired) {
110100 return ;
@@ -114,7 +104,7 @@ class _Visitor extends SimpleAstVisitor<void> {
114104 ! _isEnclosedInAsyncFunctionBody (expr) &&
115105 expr is ! AssignmentExpression ) {
116106 // TODO(srawlins): Take `@awaitNotRequired` into account.
117- _reportOnExpression ( expr);
107+ reportOnExpression (rule, expr);
118108 }
119109 }
120110}
0 commit comments