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

Unified Diff: pkg/kernel/lib/ast.dart

Issue 2988373002: Store parts in Kernel Library, resynthesize parts in Analyzer. (Closed)
Patch Set: Fixes for review comments. Created 3 years, 4 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/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 93fcd5c882380fb5d00ed69cc32f1db3978b8ba0..76c28cd75e0b694f9ecb2ea5eabbd89c73951e01 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -269,6 +269,8 @@ class Library extends NamedNode implements Comparable<Library> {
String name;
final List<Expression> annotations;
final List<LibraryDependency> dependencies;
+ @informative
+ final List<LibraryPart> parts;
final List<Typedef> typedefs;
final List<Class> classes;
final List<Procedure> procedures;
@@ -279,6 +281,7 @@ class Library extends NamedNode implements Comparable<Library> {
this.isExternal: false,
List<Expression> annotations,
List<LibraryDependency> dependencies,
+ List<LibraryPart> parts,
List<Typedef> typedefs,
List<Class> classes,
List<Procedure> procedures,
@@ -287,12 +290,14 @@ class Library extends NamedNode implements Comparable<Library> {
Reference reference})
: this.annotations = annotations ?? <Expression>[],
this.dependencies = dependencies ?? <LibraryDependency>[],
+ this.parts = parts ?? <LibraryPart>[],
this.typedefs = typedefs ?? <Typedef>[],
this.classes = classes ?? <Class>[],
this.procedures = procedures ?? <Procedure>[],
this.fields = fields ?? <Field>[],
super(reference) {
setParents(this.dependencies, this);
+ setParents(this.parts, this);
setParents(this.typedefs, this);
setParents(this.classes, this);
setParents(this.procedures, this);
@@ -353,10 +358,15 @@ class Library extends NamedNode implements Comparable<Library> {
dependencies.add(node..parent = this);
}
+ void addPart(LibraryPart node) {
+ parts.add(node..parent = this);
+ }
+
accept(TreeVisitor v) => v.visitLibrary(this);
visitChildren(Visitor v) {
visitList(dependencies, v);
+ visitList(parts, v);
visitList(typedefs, v);
visitList(classes, v);
visitList(procedures, v);
@@ -365,6 +375,7 @@ class Library extends NamedNode implements Comparable<Library> {
transformChildren(Transformer v) {
transformList(dependencies, v, this);
+ transformList(parts, v, this);
transformList(typedefs, v, this);
transformList(classes, v, this);
transformList(procedures, v, this);
@@ -463,6 +474,37 @@ class LibraryDependency extends TreeNode {
}
}
+/// A part declaration in a library.
+///
+/// part <url>;
+///
+/// optionally with metadata.
+class LibraryPart extends TreeNode {
+ final List<Expression> annotations;
+ final String fileUri;
+
+ LibraryPart(List<Expression> annotations, String fileUri)
+ : this.byReference(annotations, fileUri);
+
+ LibraryPart.byReference(this.annotations, this.fileUri) {
+ setParents(annotations, this);
+ }
+
+ void addAnnotation(Expression annotation) {
+ annotations.add(annotation..parent = this);
+ }
+
+ accept(TreeVisitor v) => v.visitLibraryPart(this);
+
+ visitChildren(Visitor v) {
+ visitList(annotations, v);
+ }
+
+ transformChildren(Transformer v) {
+ transformList(annotations, v, this);
+ }
+}
+
/// A `show` or `hide` clause for an import or export.
class Combinator extends TreeNode {
bool isShow;
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698