blob: 82ae7800a25fd5e9615e0130abbe6bbb39d4f1df [file] [log] [blame]
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
/// [RecursiveAstVisitor] that delegates visit methods to functions.
class FunctionAstVisitor extends RecursiveAstVisitor<void> {
final void Function(SimpleIdentifier) simpleIdentifier;
final void Function(VariableDeclaration) variableDeclaration;
FunctionAstVisitor({this.simpleIdentifier, this.variableDeclaration});
@override
void visitSimpleIdentifier(SimpleIdentifier node) {
if (simpleIdentifier != null) {
simpleIdentifier(node);
}
super.visitSimpleIdentifier(node);
}
@override
void visitVariableDeclaration(VariableDeclaration node) {
if (variableDeclaration != null) {
variableDeclaration(node);
}
super.visitVariableDeclaration(node);
}
}