Improve the error message produced by ThrowingAstVisitor

Change-Id: I4f4d725d52a244d9c37bc44802782f7d8e97ab9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275400
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2022-12-13 21:56:05 +00:00 committed by Commit Queue
parent 4882c0f7b3
commit 1aebb81274

View file

@ -2791,7 +2791,11 @@ class ThrowingAstVisitor<R> implements AstVisitor<R> {
R? visitYieldStatement(YieldStatement node) => _throw(node);
Never _throw(AstNode node) {
throw Exception('Missing implementation of visit${node.runtimeType}');
var typeName = node.runtimeType.toString();
if (typeName.endsWith('Impl')) {
typeName = typeName.substring(0, typeName.length - 4);
}
throw Exception('Missing implementation of visit$typeName');
}
}