Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2968093003: Improve parsing of function expressions. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/fasta/ast_builder.dart
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 8ad5b49d2e1525dd9f865f298525e34780da6a3f..e054dcc7986e192a04dc89f0c4fb4b6feaa42c5a 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -1481,12 +1481,13 @@ class AstBuilder extends ScopeListener {
comment, metadata, partKeyword, ofKeyword, uri, name, semicolon));
}
- void endUnnamedFunction(Token beginToken, Token token) {
+ @override
+ void endFunctionExpression(Token beginToken, Token token) {
// TODO(paulberry): set up scopes properly to resolve parameters and type
// variables. Note that this is tricky due to the handling of initializers
// in constructors, so the logic should be shared with BodyBuilder as much
// as possible.
- debugEvent("UnnamedFunction");
+ debugEvent("FunctionExpression");
FunctionBody body = pop();
FormalParameterList parameters = pop();
TypeParameterList typeParameters = pop();
@@ -1564,21 +1565,20 @@ class AstBuilder extends ScopeListener {
}
@override
- void endFunction(Token getOrSet, Token endToken) {
- debugEvent("Function");
+ void endNamedFunctionExpression(Token endToken) {
+ logEvent("NamedFunctionExpression");
+ }
+
+ @override
+ void endFunctionDeclaration(Token endToken) {
+ debugEvent("FunctionDeclaration");
FunctionBody body = pop();
pop(); // constructor initializers
pop(); // separator before constructor initializers
FormalParameterList parameters = pop();
TypeParameterList typeParameters = pop();
- // TODO(scheglov) It is an error if "getOrSet" is not null.
- push(ast.functionExpression(typeParameters, parameters, body));
- }
-
- @override
- void endFunctionDeclaration(Token token) {
- debugEvent("FunctionDeclaration");
- FunctionExpression functionExpression = pop();
+ FunctionExpression functionExpression =
+ ast.functionExpression(typeParameters, parameters, body);
SimpleIdentifier name = pop();
TypeAnnotation returnType = pop();
pop(); // modifiers

Powered by Google App Engine
This is Rietveld 408576698