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; |