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

Unified Diff: pkg/front_end/lib/src/fasta/source/diet_listener.dart

Issue 2987983004: Issue 30034. Parse annotations for typedef(s) and resynthesize from Kernel in analyzer. (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/front_end/lib/src/fasta/source/diet_listener.dart
diff --git a/pkg/front_end/lib/src/fasta/source/diet_listener.dart b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
index 08b0fe62c9368ffb3d43bf831078e4f570a5bcb8..506b63e8d7f0fbb084c1125a4df8805fdbd8079b 100644
--- a/pkg/front_end/lib/src/fasta/source/diet_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
@@ -4,7 +4,9 @@
library fasta.diet_listener;
-import 'package:kernel/ast.dart' show AsyncMarker, Class, InterfaceType;
+import 'package:kernel/ast.dart'
+ show AsyncMarker, Class, InterfaceType, Typedef;
+import 'package:kernel/ast.dart';
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
@@ -195,12 +197,22 @@ class DietListener extends StackListener {
void endFunctionTypeAlias(
Token typedefKeyword, Token equals, Token endToken) {
debugEvent("FunctionTypeAlias");
- if (equals != null) {
- // This is a `typedef NAME = TYPE`.
- discard(2); // Name and metadata.
- } else {
- discard(3); // Name, endToken, and metadata.
+
+ if (equals == null) pop(); // endToken
+ String name = pop();
+ Token metadata = pop();
+
+ Builder typedefBuilder = lookupBuilder(typedefKeyword, null, name);
+
+ if (metadata != null) {
+ var listener = createListener(typedefBuilder, memberScope, false);
Siggi Cherem (dart-lang) 2017/07/28 00:05:14 could we pull this out into a common function? It
scheglov 2017/08/01 17:10:21 Done.
+ var parser = new Parser(listener);
+ parser.parseMetadataStar(metadata);
+ List<Expression> metadataConstants = listener.finishMetadata();
+ Typedef type = typedefBuilder.target;
+ metadataConstants.forEach(type.addAnnotation);
}
+
checkEmpty(typedefKeyword.charOffset);
}
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart ('k') | pkg/front_end/testcases/ast_builder.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698