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

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

Issue 2803113002: Fix for parsing named factory constructors with Fasta. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0a3a9b05a7cec6304088911a6bbce171c1d686f2..96efce12a2138203b500fda7cba27febc9bbc66b 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -1548,15 +1548,31 @@ class AstBuilder extends ScopeListener {
_Modifiers modifiers = pop();
List<Annotation> metadata = pop();
Comment comment = pop();
+
+ // Decompose the preliminary ConstructorName into the type name and
+ // the actual constructor name.
+ SimpleIdentifier returnType;
+ analyzer.Token period;
+ SimpleIdentifier name;
+ Identifier typeName = constructorName.type.name;
+ if (typeName is SimpleIdentifier) {
+ returnType = typeName;
+ } else if (typeName is PrefixedIdentifier) {
+ returnType = typeName.prefix;
+ period = typeName.period;
+ name =
+ ast.simpleIdentifier(typeName.identifier.token, isDeclaration: true);
+ }
+
push(ast.constructorDeclaration(
comment,
metadata,
toAnalyzerToken(modifiers?.externalKeyword),
toAnalyzerToken(modifiers?.finalConstOrVarKeyword),
- toAnalyzerToken(factoryKeyword),
- constructorName.type.name,
- constructorName.period,
- constructorName.name,
+ factoryKeyword,
Paul Berry 2017/04/06 20:36:51 Analyzer and Fasta token types have been partially
scheglov 2017/04/06 21:11:38 Done.
+ ast.simpleIdentifier(returnType.token),
+ period,
+ name,
parameters,
toAnalyzerToken(separator),
null,
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698