Index: pkg/kernel/lib/ast.dart |
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart |
index 93fcd5c882380fb5d00ed69cc32f1db3978b8ba0..2c469923a7688375027492d209a81d084fb95fcd 100644 |
--- a/pkg/kernel/lib/ast.dart |
+++ b/pkg/kernel/lib/ast.dart |
@@ -269,6 +269,7 @@ class Library extends NamedNode implements Comparable<Library> { |
String name; |
final List<Expression> annotations; |
final List<LibraryDependency> dependencies; |
+ final List<LibraryPart> parts; |
Siggi Cherem (dart-lang)
2017/08/02 23:06:23
should we add @informational to this field?
scheglov
2017/08/03 00:16:35
Acknowledged.
|
final List<Typedef> typedefs; |
final List<Class> classes; |
final List<Procedure> procedures; |
@@ -279,6 +280,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 +289,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 +357,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); |
@@ -463,6 +472,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; |