sort ForwardingListener and ForwardingTestListener

Change-Id: Ib94c0c57acb8e3e4271e51205511aee4f087f3fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114641
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
danrubel 2019-08-27 17:54:52 +00:00 committed by commit-bot@chromium.org
parent aeb5e732fd
commit 0328e8a7b6
2 changed files with 62 additions and 62 deletions

View file

@ -32,34 +32,13 @@ import 'package:test/test.dart';
class ForwardingTestListener extends ForwardingListener {
final _stack = <String>[];
ForwardingTestListener([Listener listener]) : super(listener);
void begin(String event) {
expect(event, isNotNull);
_stack.add(event);
}
void expectEmpty() {
expect(_stack, isEmpty);
}
void expectIn(String event) {
if (_stack.isEmpty || _stack.last != event) {
fail('Expected $event, but found $_stack');
}
}
void expectInOneOf(List<String> events) {
if (_stack.isEmpty || !events.contains(_stack.last)) {
fail('Expected one of $events, but found $_stack');
}
}
void end(String event) {
expectIn(event);
_stack.removeLast();
}
ForwardingTestListener([Listener listener]) : super(listener);
@override
void beginArguments(Token token) {
super.beginArguments(token);
@ -558,6 +537,11 @@ class ForwardingTestListener extends ForwardingListener {
begin('YieldStatement');
}
void end(String event) {
expectIn(event);
_stack.removeLast();
}
@override
void endArguments(int count, Token beginToken, Token endToken) {
end('Arguments');
@ -578,13 +562,6 @@ class ForwardingTestListener extends ForwardingListener {
super.endAwaitExpression(beginToken, endToken);
}
@override
void endInvalidAwaitExpression(
Token beginToken, Token endToken, MessageCode errorCode) {
end('InvalidAwaitExpression');
super.endInvalidAwaitExpression(beginToken, endToken, errorCode);
}
@override
void endBlock(int count, Token beginToken, Token endToken) {
end('Block');
@ -622,6 +599,13 @@ class ForwardingTestListener extends ForwardingListener {
super.endClassDeclaration(beginToken, endToken);
}
@override
void endClassFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
end('FactoryMethod');
super.endClassFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endClassOrMixinBody(
ClassKind kind, int memberCount, Token beginToken, Token endToken) {
@ -711,20 +695,6 @@ class ForwardingTestListener extends ForwardingListener {
end('ExtensionDeclaration');
}
@override
void endClassFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
end('FactoryMethod');
super.endClassFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endMixinFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
end('FactoryMethod');
super.endMixinFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endExtensionFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
@ -889,6 +859,13 @@ class ForwardingTestListener extends ForwardingListener {
super.endInitializers(count, beginToken, endToken);
}
@override
void endInvalidAwaitExpression(
Token beginToken, Token endToken, MessageCode errorCode) {
end('InvalidAwaitExpression');
super.endInvalidAwaitExpression(beginToken, endToken, errorCode);
}
@override
void endLabeledStatement(int labelCount) {
end('LabeledStatement');
@ -952,6 +929,13 @@ class ForwardingTestListener extends ForwardingListener {
super.endMixinDeclaration(mixinKeyword, endToken);
}
@override
void endMixinFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
end('FactoryMethod');
super.endMixinFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endNamedFunctionExpression(Token endToken) {
end('NamedFunctionExpression');
@ -1139,6 +1123,22 @@ class ForwardingTestListener extends ForwardingListener {
super.endYieldStatement(yieldToken, starToken, endToken);
}
void expectEmpty() {
expect(_stack, isEmpty);
}
void expectIn(String event) {
if (_stack.isEmpty || _stack.last != event) {
fail('Expected $event, but found $_stack');
}
}
void expectInOneOf(List<String> events) {
if (_stack.isEmpty || !events.contains(_stack.last)) {
fail('Expected one of $events, but found $_stack');
}
}
@override
void handleClassExtends(Token extendsKeyword) {
expectIn('ClassDeclaration');

View file

@ -479,12 +479,6 @@ class ForwardingListener implements Listener {
listener?.endAwaitExpression(beginToken, endToken);
}
@override
void endInvalidAwaitExpression(
Token beginToken, Token endToken, MessageCode errorCode) {
listener?.endInvalidAwaitExpression(beginToken, endToken, errorCode);
}
@override
void endBinaryExpression(Token token) {
listener?.endBinaryExpression(token);
@ -520,6 +514,12 @@ class ForwardingListener implements Listener {
listener?.endClassDeclaration(beginToken, endToken);
}
@override
void endClassFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
listener?.endClassFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endClassOrMixinBody(
ClassKind kind, int memberCount, Token beginToken, Token endToken) {
@ -599,18 +599,6 @@ class ForwardingListener implements Listener {
listener?.endExtensionDeclaration(extensionKeyword, onKeyword, token);
}
@override
void endClassFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
listener?.endClassFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endMixinFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
listener?.endMixinFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endExtensionFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
@ -759,6 +747,12 @@ class ForwardingListener implements Listener {
listener?.endInitializers(count, beginToken, endToken);
}
@override
void endInvalidAwaitExpression(
Token beginToken, Token endToken, MessageCode errorCode) {
listener?.endInvalidAwaitExpression(beginToken, endToken, errorCode);
}
@override
void endLabeledStatement(int labelCount) {
listener?.endLabeledStatement(labelCount);
@ -811,6 +805,12 @@ class ForwardingListener implements Listener {
listener?.endMixinDeclaration(mixinKeyword, endToken);
}
@override
void endMixinFactoryMethod(
Token beginToken, Token factoryKeyword, Token endToken) {
listener?.endMixinFactoryMethod(beginToken, factoryKeyword, endToken);
}
@override
void endNamedFunctionExpression(Token endToken) {
listener?.endNamedFunctionExpression(endToken);