File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -289,8 +289,12 @@ class GeneralizingAstVisitor<R> implements AstVisitor<R> {
289289 R ? visitFunctionBody (FunctionBody node) => visitNode (node);
290290
291291 @override
292- R ? visitFunctionDeclaration (FunctionDeclaration node) =>
293- visitNamedCompilationUnitMember (node);
292+ R ? visitFunctionDeclaration (FunctionDeclaration node) {
293+ if (node.parent is FunctionDeclarationStatement ) {
294+ return visitNode (node);
295+ }
296+ return visitNamedCompilationUnitMember (node);
297+ }
294298
295299 @override
296300 R ? visitFunctionDeclarationStatement (FunctionDeclarationStatement node) =>
Original file line number Diff line number Diff line change @@ -216,13 +216,27 @@ class GeneralizingAstVisitor<R> implements AstVisitor<R> {
216216 if (node.isConcrete) {
217217 out.writeln ('@override' );
218218 }
219+
220+ // TODO(fshcheglov): Remove special case after AST hierarchy is fixed.
221+ // https://github.com/dart-lang/sdk/issues/61224
222+ if (node.name == 'FunctionDeclaration' ) {
223+ out.writeln (r'''
224+ R? visitFunctionDeclaration(FunctionDeclaration node) {
225+ if (node.parent is FunctionDeclarationStatement) {
226+ return visitNode(node);
227+ }
228+ return visitNamedCompilationUnitMember(node);
229+ }''' );
230+ continue ;
231+ }
232+
219233 if (superNode.element.isAstNodeImplExactly) {
220234 out.writeln ('''
221- R? visit$name ($name node) => visitNode(node);
235+ R? visit$name ($name node) => visitNode(node);
222236''' );
223237 } else {
224238 out.writeln ('''
225- R? visit$name ($name node) => visit${superNode .name }(node);
239+ R? visit$name ($name node) => visit${superNode .name }(node);
226240''' );
227241 }
228242 }
You can’t perform that action at this time.
0 commit comments