Skip to content

Commit

Permalink
Update endFunctionType event to take questionMark token
Browse files Browse the repository at this point in the history
... which in this CL will always null.
This is another step when adding NNDB support as outlined in
dart-lang/language#110

Change-Id: I3974fcb885c63be4af9d1007258383f3f8191ae0
Reviewed-on: https://dart-review.googlesource.com/c/87080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
  • Loading branch information
Dan Rubel authored and commit-bot@chromium.org committed Dec 12, 2018
1 parent 15d65fb commit 1ff82c5
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 32 deletions.
3 changes: 2 additions & 1 deletion pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1118,9 +1118,10 @@ class AstBuilder extends StackListener {
}

@override
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
assert(optional('Function', functionToken));
debugEvent("FunctionType");
reportErrorIfNullableType(questionMark);

FormalParameterList parameters = pop();
TypeAnnotation returnType = pop();
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/test/generated/parser_fasta_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,9 @@ class ForwardingTestListener extends ForwardingListener {
}

@override
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
end('FunctionType');
super.endFunctionType(functionToken);
super.endFunctionType(functionToken, questionMark);
}

@override
Expand Down
3 changes: 2 additions & 1 deletion pkg/front_end/lib/src/fasta/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2540,8 +2540,9 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
}

@override
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
debugEvent("FunctionType");
reportErrorIfNullableType(questionMark);
FormalParameters formals = pop();
UnresolvedType<KernelTypeBuilder> returnType = pop();
List<KernelTypeVariableBuilder> typeVariables = pop();
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/fasta/parser/forwarding_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ class ForwardingListener implements Listener {
}

@override
void endFunctionType(Token functionToken) {
listener?.endFunctionType(functionToken);
void endFunctionType(Token functionToken, Token questionMark) {
listener?.endFunctionType(functionToken, questionMark);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/fasta/parser/listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ class Listener implements UnescapeErrorListener {
/// - Type variables
/// - Return type
/// - Formal parameters
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
logEvent("FunctionType");
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/fasta/parser/type_info_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class ComplexTypeInfo implements TypeInfo {
--endGroupIndex;
token = parser.parseFormalParametersRequiredOpt(
token, MemberKind.GeneralizedFunctionType);
parser.listener.endFunctionType(functionToken);
parser.listener.endFunctionType(functionToken, null);
}

// There are two situations in which the [token] != [end]:
Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/fasta/source/diet_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class DietListener extends StackListener {
}

@override
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
debugEvent("FunctionType");
discard(1);
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/front_end/lib/src/fasta/source/outline_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,9 @@ class OutlineBuilder extends StackListener {
}

@override
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
debugEvent("FunctionType");
reportErrorIfNullableType(questionMark);
List<FormalParameterBuilder> formals = pop();
pop(); // formals offset
TypeBuilder returnType = pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ class TypePromotionLookAheadListener extends Listener {
}

@override
void endFunctionType(Token functionToken) {
void endFunctionType(Token functionToken, Token questionMark) {
debugEvent("FunctionType", functionToken);
}

Expand Down
42 changes: 21 additions & 21 deletions pkg/front_end/test/fasta/parser/type_info_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ class TypeInfoTest {
'handleNoType ',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
expectComplexInfo('Function<T>() m', expectedAfter: 'm', expectedCalls: [
'beginTypeVariables <',
Expand All @@ -716,7 +716,7 @@ class TypeInfoTest {
'handleNoType ',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
expectComplexInfo('Function(int) m', expectedAfter: 'm', expectedCalls: [
'handleNoTypeVariables (',
Expand All @@ -734,7 +734,7 @@ class TypeInfoTest {
'endFormalParameter null null ) FormalParameterKind.mandatory '
'MemberKind.GeneralizedFunctionType',
'endFormalParameters 1 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
expectComplexInfo('Function<T>(int) m', expectedAfter: 'm', expectedCalls: [
'beginTypeVariables <',
Expand All @@ -760,7 +760,7 @@ class TypeInfoTest {
'endFormalParameter null null ) FormalParameterKind.mandatory'
' MemberKind.GeneralizedFunctionType',
'endFormalParameters 1 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);

expectComplexInfo('Function(int x)', required: true);
Expand Down Expand Up @@ -796,7 +796,7 @@ class TypeInfoTest {
'handleType C null',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
}

Expand Down Expand Up @@ -878,7 +878,7 @@ class TypeInfoTest {
'handleType C null',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
expectComplexInfo('C<T> Function<T>(int x) Function<T>(int x)',
required: false, expectedAfter: 'Function');
Expand Down Expand Up @@ -992,7 +992,7 @@ class TypeInfoTest {
'handleType C null',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
expectComplexInfo('C.a Function<T>(int x) Function<T>(int x)',
required: false, expectedAfter: 'Function');
Expand Down Expand Up @@ -1071,7 +1071,7 @@ class TypeInfoTest {
'endFormalParameter null null x FormalParameterKind.mandatory '
'MemberKind.GeneralizedFunctionType',
'endFormalParameters 1 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'beginMetadataStar int',
'endMetadataStar 0',
Expand All @@ -1084,7 +1084,7 @@ class TypeInfoTest {
'endFormalParameter null null x FormalParameterKind.mandatory '
'MemberKind.GeneralizedFunctionType',
'endFormalParameters 1 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
}

Expand All @@ -1097,7 +1097,7 @@ class TypeInfoTest {
'handleVoidKeyword void',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);
}

Expand All @@ -1108,7 +1108,7 @@ class TypeInfoTest {
'handleVoidKeyword void',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
]);

expectComplexInfo('void Function<T>()', required: true);
Expand Down Expand Up @@ -1367,7 +1367,7 @@ class TypeParamOrArgInfoTest {
'handleType S null',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeArguments 1 < >'
]);
expectComplexTypeArg('<void Function()>',
Expand All @@ -1379,7 +1379,7 @@ class TypeParamOrArgInfoTest {
'handleVoidKeyword void',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeArguments 1 < >'
]);
expectComplexTypeArg('<S<T>>', typeArgumentCount: 1, expectedCalls: [
Expand Down Expand Up @@ -1451,7 +1451,7 @@ class TypeParamOrArgInfoTest {
'handleNoType <',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeArguments 1 < >',
'handleType S null',
'endTypeArguments 1 < >'
Expand All @@ -1468,7 +1468,7 @@ class TypeParamOrArgInfoTest {
'handleNoType <',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeArguments 1 < >',
'handleType S null',
'endTypeArguments 1 < >'
Expand All @@ -1484,7 +1484,7 @@ class TypeParamOrArgInfoTest {
'handleVoidKeyword void', // was 'handleNoType <'
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeArguments 1 < >',
'handleType S null',
'endTypeArguments 1 < >'
Expand All @@ -1502,7 +1502,7 @@ class TypeParamOrArgInfoTest {
'handleVoidKeyword void', // was 'handleNoType <'
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeArguments 1 < >',
'handleType T null',
'endTypeArguments 1 < >',
Expand Down Expand Up @@ -1680,7 +1680,7 @@ class TypeParamOrArgInfoTest {
'handleVoidKeyword void',
'beginFormalParameters ( MemberKind.GeneralizedFunctionType',
'endFormalParameters 0 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeVariable > 1 extends',
'handleNoType R',
'endTypeVariable , 0 null',
Expand Down Expand Up @@ -1943,7 +1943,7 @@ class TypeParamOrArgInfoTest {
'handleFormalParameterWithoutValue )',
'endFormalParameter null null ) FormalParameterKind.mandatory MemberKind.GeneralizedFunctionType',
'endFormalParameters 1 ( ) MemberKind.GeneralizedFunctionType',
'endFunctionType Function',
'endFunctionType Function null',
'endTypeVariable > 0 extends',
'endTypeVariables < >'
]);
Expand Down Expand Up @@ -2339,8 +2339,8 @@ class TypeInfoListener implements Listener {
}

@override
void endFunctionType(Token functionToken) {
calls.add('endFunctionType $functionToken');
void endFunctionType(Token functionToken, Token questionMark) {
calls.add('endFunctionType $functionToken $questionMark');
}

@override
Expand Down

0 comments on commit 1ff82c5

Please sign in to comment.