mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:37:53 +00:00
Add metadata annotations to library definitions.
BUG= R=ahe@google.com Review-Url: https://codereview.chromium.org/2893803003 .
This commit is contained in:
parent
ef3d2c8ce2
commit
1ea216e6de
|
@ -166,6 +166,7 @@ type Library {
|
|||
StringReference name;
|
||||
// An absolute path URI to the .dart file from which the library was created.
|
||||
UriReference fileUri;
|
||||
List<Expression> annotations;
|
||||
List<LibraryDependency> libraryDependencies;
|
||||
List<Class> classes;
|
||||
List<Field> fields;
|
||||
|
|
|
@ -264,6 +264,7 @@ class Library extends NamedNode implements Comparable<Library> {
|
|||
bool isExternal;
|
||||
|
||||
String name;
|
||||
final List<Expression> annotations;
|
||||
final List<LibraryDependency> dependencies;
|
||||
final List<Typedef> typedefs;
|
||||
final List<Class> classes;
|
||||
|
@ -273,6 +274,7 @@ class Library extends NamedNode implements Comparable<Library> {
|
|||
Library(this.importUri,
|
||||
{this.name,
|
||||
this.isExternal: false,
|
||||
List<Expression> annotations,
|
||||
List<LibraryDependency> dependencies,
|
||||
List<Typedef> typedefs,
|
||||
List<Class> classes,
|
||||
|
@ -280,7 +282,8 @@ class Library extends NamedNode implements Comparable<Library> {
|
|||
List<Field> fields,
|
||||
this.fileUri,
|
||||
Reference reference})
|
||||
: this.dependencies = dependencies ?? <LibraryDependency>[],
|
||||
: this.annotations = annotations ?? <Expression>[],
|
||||
this.dependencies = dependencies ?? <LibraryDependency>[],
|
||||
this.typedefs = typedefs ?? <Typedef>[],
|
||||
this.classes = classes ?? <Class>[],
|
||||
this.procedures = procedures ?? <Procedure>[],
|
||||
|
@ -321,6 +324,11 @@ class Library extends NamedNode implements Comparable<Library> {
|
|||
typedefs.add(typedef_);
|
||||
}
|
||||
|
||||
void addAnnotation(Expression node) {
|
||||
node.parent = this;
|
||||
annotations.add(node);
|
||||
}
|
||||
|
||||
void computeCanonicalNames() {
|
||||
assert(canonicalName != null);
|
||||
for (var typedef_ in typedefs) {
|
||||
|
|
|
@ -354,10 +354,10 @@ class BinaryBuilder {
|
|||
library.fileUri = fileUri;
|
||||
}
|
||||
|
||||
_readLibraryDependencies(library);
|
||||
|
||||
debugPath.add(library.name ?? library.importUri?.toString() ?? 'library');
|
||||
|
||||
_fillTreeNodeList(library.annotations, readExpression, library);
|
||||
_readLibraryDependencies(library);
|
||||
_mergeNamedNodeList(library.typedefs, readTypedef, library);
|
||||
_mergeNamedNodeList(library.classes, readClass, library);
|
||||
_mergeNamedNodeList(library.fields, readField, library);
|
||||
|
|
|
@ -255,6 +255,7 @@ class BinaryPrinter extends Visitor {
|
|||
writeStringReference(node.name ?? '');
|
||||
// TODO(jensj): We save (almost) the same URI twice.
|
||||
writeUriReference(node.fileUri ?? '');
|
||||
writeAnnotationList(node.annotations);
|
||||
writeLibraryDependencies(node);
|
||||
writeNodeList(node.typedefs);
|
||||
writeNodeList(node.classes);
|
||||
|
|
|
@ -265,6 +265,7 @@ class Printer extends Visitor<Null> {
|
|||
}
|
||||
|
||||
void writeLibraryFile(Library library) {
|
||||
writeAnnotationList(library.annotations);
|
||||
writeWord('library');
|
||||
if (library.name != null) {
|
||||
writeWord(library.name);
|
||||
|
@ -308,6 +309,7 @@ class Printer extends Visitor<Null> {
|
|||
}
|
||||
writeWord('external');
|
||||
}
|
||||
writeAnnotationList(library.annotations);
|
||||
writeWord('library');
|
||||
if (library.name != null) {
|
||||
writeWord(library.name);
|
||||
|
|
|
@ -53,6 +53,7 @@ void Library::AcceptTreeVisitor(TreeVisitor* visitor) {
|
|||
|
||||
|
||||
void Library::VisitChildren(Visitor* visitor) {
|
||||
VisitList(&typedefs(), visitor);
|
||||
VisitList(&classes(), visitor);
|
||||
VisitList(&procedures(), visitor);
|
||||
VisitList(&fields(), visitor);
|
||||
|
|
|
@ -474,6 +474,7 @@ class Library : public LinkedNode {
|
|||
StringIndex import_uri() { return import_uri_index_; }
|
||||
intptr_t source_uri_index() { return source_uri_index_; }
|
||||
StringIndex name() { return name_index_; }
|
||||
List<Expression>& annotations() { return annotations_; }
|
||||
List<LibraryDependency>& dependencies() { return dependency_; }
|
||||
List<Typedef>& typedefs() { return typedefs_; }
|
||||
List<Class>& classes() { return classes_; }
|
||||
|
@ -492,6 +493,7 @@ class Library : public LinkedNode {
|
|||
StringIndex name_index_;
|
||||
StringIndex import_uri_index_;
|
||||
intptr_t source_uri_index_;
|
||||
List<Expression> annotations_;
|
||||
List<LibraryDependency> dependency_;
|
||||
List<Typedef> typedefs_;
|
||||
List<Class> classes_;
|
||||
|
|
|
@ -182,6 +182,7 @@ Library* Library::ReadFrom(Reader* reader) {
|
|||
source_uri_index_ = reader->ReadUInt();
|
||||
reader->set_current_script_id(source_uri_index_);
|
||||
|
||||
annotations_.ReadFromStatic<Expression>(reader);
|
||||
dependencies().ReadFromStatic<LibraryDependency>(reader);
|
||||
int num_typedefs = reader->ReadUInt();
|
||||
typedefs().EnsureInitialized(num_typedefs);
|
||||
|
|
Loading…
Reference in a new issue