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

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

Issue 2567133002: Add support for the new function-type syntax. (Closed)
Patch Set: Address comments for ast_builder.dart Created 3 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | pkg/front_end/lib/src/fasta/kernel/body_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
index a63af7f9ac69314a36f08e0b54e96eb0793914d4..1331632efd400e7e4ecdd0f9a8e7bfefec5e5b35 100644
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
@@ -439,7 +439,7 @@ class AstBuilder extends ScopeListener {
push(ast.symbolLiteral(toAnalyzerToken(hashToken), components));
}
- void endType(Token beginToken, Token endToken) {
+ void handleType(Token beginToken, Token endToken) {
debugEvent("Type");
TypeArgumentList arguments = pop();
Identifier name = pop();
@@ -1097,28 +1097,52 @@ class AstBuilder extends ScopeListener {
// keyword up to an element?
handleIdentifier(token);
handleNoTypeArguments(token);
- endType(token, token);
+ handleType(token, token);
}
@override
- void endFunctionTypeAlias(Token typedefKeyword, Token endToken) {
+ void endFunctionTypeAlias(
+ Token typedefKeyword, Token equals, Token endToken) {
debugEvent("FunctionTypeAlias");
- FormalParameterList parameters = pop();
- TypeParameterList typeParameters = pop();
- SimpleIdentifier name = pop();
- TypeAnnotation returnType = pop();
- List<Annotation> metadata = pop();
- // TODO(paulberry): capture doc comments. See dartbug.com/28851.
- Comment comment = null;
- push(ast.functionTypeAlias(
- comment,
- metadata,
- toAnalyzerToken(typedefKeyword),
- returnType,
- name,
- typeParameters,
- parameters,
- toAnalyzerToken(endToken)));
+ if (equals == null) {
+ FormalParameterList parameters = pop();
+ TypeParameterList typeParameters = pop();
+ SimpleIdentifier name = pop();
+ TypeAnnotation returnType = pop();
+ List<Annotation> metadata = pop();
+ // TODO(paulberry): capture doc comments. See dartbug.com/28851.
+ Comment comment = null;
+ push(ast.functionTypeAlias(
+ comment,
+ metadata,
+ toAnalyzerToken(typedefKeyword),
+ returnType,
+ name,
+ typeParameters,
+ parameters,
+ toAnalyzerToken(endToken)));
+ } else {
+ TypeAnnotation type = pop();
+ TypeParameterList templateParameters = pop();
+ SimpleIdentifier name = pop();
+ List<Annotation> metadata = pop();
+ // TODO(paulberry): capture doc comments. See dartbug.com/28851.
+ Comment comment = null;
+ if (type is! GenericFunctionType) {
+ // TODO(brianwilkerson) Generate an error and recover (better than
Paul Berry 2017/02/22 19:28:36 Feel free to assign this TODO to me.
floitsch 2017/02/23 12:15:19 Done.
+ // this).
+ type = null;
+ }
+ push(ast.genericTypeAlias(
+ comment,
+ metadata,
+ toAnalyzerToken(typedefKeyword),
+ name,
+ templateParameters,
+ toAnalyzerToken(equals),
+ type,
+ toAnalyzerToken(endToken)));
+ }
}
/**
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | pkg/front_end/lib/src/fasta/kernel/body_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698