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

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

Issue 2723883002: Add AstBuilder support for fields. (Closed)
Patch Set: 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
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 5a14cae0ff85418224322eeffdf0f131ad1e142a..35a38ec3d38d931e1f54350af2c603d7e494282f 100644
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
@@ -1311,6 +1311,42 @@ class AstBuilder extends ScopeListener {
}
@override
+ void endFields(
+ int count, Token covariantKeyword, Token beginToken, Token endToken) {
+ debugEvent("Fields");
+ List<VariableDeclaration> variables = popList(count);
+ TypeAnnotation type = pop();
+ List<Token> modifiers = pop();
+ Token staticKeyword;
+ Token keyword;
+ for (Token modifier in modifiers) {
ahe 2017/03/01 15:20:31 Would it make sense to have something more like pk
Paul Berry 2017/03/01 21:08:22 Unfortunately that wouldn't be quite enough; the a
+ String value = modifier.stringValue;
+ if (identical('static', value)) {
+ // TODO(paulberry): Check the order and uniqueness.
ahe 2017/03/01 15:20:31 I think we should have the parser do that (while s
Paul Berry 2017/03/01 21:08:22 Agreed. There are several TODOs that say this, so
+ staticKeyword = modifier;
+ } else if (identical('var', value)) {
+ // TODO(paulberry): Check the order and uniqueness.
+ keyword = modifier;
+ } else {
+ // TODO(paulberry): Report error.
+ internalError("Invalid modifier ($value). Report an error.");
+ }
+ }
+ var variableList = ast.variableDeclarationList(
+ null, null, toAnalyzerToken(keyword), type, variables);
+ List<Annotation> metadata = pop();
+ // TODO(paulberry): capture doc comments. See dartbug.com/28851.
+ Comment comment = null;
+ push(ast.fieldDeclaration2(
+ comment: comment,
+ metadata: metadata,
+ covariantKeyword: toAnalyzerToken(covariantKeyword),
+ staticKeyword: toAnalyzerToken(staticKeyword),
+ fieldList: variableList,
+ semicolon: toAnalyzerToken(endToken)));
+ }
+
+ @override
void handleOperatorName(Token operatorKeyword, Token token) {
debugEvent("OperatorName");
push(new _OperatorName(operatorKeyword,

Powered by Google App Engine
This is Rietveld 408576698