OLD | NEW |
---|---|
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
8 /// | 8 /// |
9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 /// other than [ClassLevel.Body]. Members in an external library have no | 262 /// other than [ClassLevel.Body]. Members in an external library have no |
263 /// body, but have their typed interface present. | 263 /// body, but have their typed interface present. |
264 /// | 264 /// |
265 /// If the libary is non-external, then its classes are at [ClassLevel.Body] | 265 /// If the libary is non-external, then its classes are at [ClassLevel.Body] |
266 /// and all members are loaded. | 266 /// and all members are loaded. |
267 bool isExternal; | 267 bool isExternal; |
268 | 268 |
269 String name; | 269 String name; |
270 final List<Expression> annotations; | 270 final List<Expression> annotations; |
271 final List<LibraryDependency> dependencies; | 271 final List<LibraryDependency> dependencies; |
272 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.
| |
272 final List<Typedef> typedefs; | 273 final List<Typedef> typedefs; |
273 final List<Class> classes; | 274 final List<Class> classes; |
274 final List<Procedure> procedures; | 275 final List<Procedure> procedures; |
275 final List<Field> fields; | 276 final List<Field> fields; |
276 | 277 |
277 Library(this.importUri, | 278 Library(this.importUri, |
278 {this.name, | 279 {this.name, |
279 this.isExternal: false, | 280 this.isExternal: false, |
280 List<Expression> annotations, | 281 List<Expression> annotations, |
281 List<LibraryDependency> dependencies, | 282 List<LibraryDependency> dependencies, |
283 List<LibraryPart> parts, | |
282 List<Typedef> typedefs, | 284 List<Typedef> typedefs, |
283 List<Class> classes, | 285 List<Class> classes, |
284 List<Procedure> procedures, | 286 List<Procedure> procedures, |
285 List<Field> fields, | 287 List<Field> fields, |
286 this.fileUri, | 288 this.fileUri, |
287 Reference reference}) | 289 Reference reference}) |
288 : this.annotations = annotations ?? <Expression>[], | 290 : this.annotations = annotations ?? <Expression>[], |
289 this.dependencies = dependencies ?? <LibraryDependency>[], | 291 this.dependencies = dependencies ?? <LibraryDependency>[], |
292 this.parts = parts ?? <LibraryPart>[], | |
290 this.typedefs = typedefs ?? <Typedef>[], | 293 this.typedefs = typedefs ?? <Typedef>[], |
291 this.classes = classes ?? <Class>[], | 294 this.classes = classes ?? <Class>[], |
292 this.procedures = procedures ?? <Procedure>[], | 295 this.procedures = procedures ?? <Procedure>[], |
293 this.fields = fields ?? <Field>[], | 296 this.fields = fields ?? <Field>[], |
294 super(reference) { | 297 super(reference) { |
295 setParents(this.dependencies, this); | 298 setParents(this.dependencies, this); |
299 setParents(this.parts, this); | |
296 setParents(this.typedefs, this); | 300 setParents(this.typedefs, this); |
297 setParents(this.classes, this); | 301 setParents(this.classes, this); |
298 setParents(this.procedures, this); | 302 setParents(this.procedures, this); |
299 setParents(this.fields, this); | 303 setParents(this.fields, this); |
300 } | 304 } |
301 | 305 |
302 /// Returns the top-level fields and procedures defined in this library. | 306 /// Returns the top-level fields and procedures defined in this library. |
303 /// | 307 /// |
304 /// This getter is for convenience, not efficiency. Consider manually | 308 /// This getter is for convenience, not efficiency. Consider manually |
305 /// iterating the members to speed up code in production. | 309 /// iterating the members to speed up code in production. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 for (var class_ in classes) { | 350 for (var class_ in classes) { |
347 canonicalName.getChild(class_.name).bindTo(class_.reference); | 351 canonicalName.getChild(class_.name).bindTo(class_.reference); |
348 class_.computeCanonicalNames(); | 352 class_.computeCanonicalNames(); |
349 } | 353 } |
350 } | 354 } |
351 | 355 |
352 void addDependency(LibraryDependency node) { | 356 void addDependency(LibraryDependency node) { |
353 dependencies.add(node..parent = this); | 357 dependencies.add(node..parent = this); |
354 } | 358 } |
355 | 359 |
360 void addPart(LibraryPart node) { | |
361 parts.add(node..parent = this); | |
362 } | |
363 | |
356 accept(TreeVisitor v) => v.visitLibrary(this); | 364 accept(TreeVisitor v) => v.visitLibrary(this); |
357 | 365 |
358 visitChildren(Visitor v) { | 366 visitChildren(Visitor v) { |
359 visitList(dependencies, v); | 367 visitList(dependencies, v); |
368 visitList(parts, v); | |
360 visitList(typedefs, v); | 369 visitList(typedefs, v); |
361 visitList(classes, v); | 370 visitList(classes, v); |
362 visitList(procedures, v); | 371 visitList(procedures, v); |
363 visitList(fields, v); | 372 visitList(fields, v); |
364 } | 373 } |
365 | 374 |
366 transformChildren(Transformer v) { | 375 transformChildren(Transformer v) { |
367 transformList(dependencies, v, this); | 376 transformList(dependencies, v, this); |
368 transformList(typedefs, v, this); | 377 transformList(typedefs, v, this); |
369 transformList(classes, v, this); | 378 transformList(classes, v, this); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 visitList(annotations, v); | 465 visitList(annotations, v); |
457 visitList(combinators, v); | 466 visitList(combinators, v); |
458 } | 467 } |
459 | 468 |
460 transformChildren(Transformer v) { | 469 transformChildren(Transformer v) { |
461 transformList(annotations, v, this); | 470 transformList(annotations, v, this); |
462 transformList(combinators, v, this); | 471 transformList(combinators, v, this); |
463 } | 472 } |
464 } | 473 } |
465 | 474 |
475 /// A part declaration in a library. | |
476 /// | |
477 /// part <url>; | |
478 /// | |
479 /// optionally with metadata. | |
480 class LibraryPart extends TreeNode { | |
481 final List<Expression> annotations; | |
482 final String fileUri; | |
483 | |
484 LibraryPart(List<Expression> annotations, String fileUri) | |
485 : this.byReference(annotations, fileUri); | |
486 | |
487 LibraryPart.byReference(this.annotations, this.fileUri) { | |
488 setParents(annotations, this); | |
489 } | |
490 | |
491 void addAnnotation(Expression annotation) { | |
492 annotations.add(annotation..parent = this); | |
493 } | |
494 | |
495 accept(TreeVisitor v) => v.visitLibraryPart(this); | |
496 | |
497 visitChildren(Visitor v) { | |
498 visitList(annotations, v); | |
499 } | |
500 | |
501 transformChildren(Transformer v) { | |
502 transformList(annotations, v, this); | |
503 } | |
504 } | |
505 | |
466 /// A `show` or `hide` clause for an import or export. | 506 /// A `show` or `hide` clause for an import or export. |
467 class Combinator extends TreeNode { | 507 class Combinator extends TreeNode { |
468 bool isShow; | 508 bool isShow; |
469 final List<String> names; | 509 final List<String> names; |
470 | 510 |
471 LibraryDependency get dependency => parent; | 511 LibraryDependency get dependency => parent; |
472 | 512 |
473 Combinator(this.isShow, this.names); | 513 Combinator(this.isShow, this.names); |
474 Combinator.show(this.names) : isShow = true; | 514 Combinator.show(this.names) : isShow = true; |
475 Combinator.hide(this.names) : isShow = false; | 515 Combinator.hide(this.names) : isShow = false; |
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4691 if (typedef_.canonicalName == null) { | 4731 if (typedef_.canonicalName == null) { |
4692 throw '$typedef_ has no canonical name'; | 4732 throw '$typedef_ has no canonical name'; |
4693 } | 4733 } |
4694 return typedef_.canonicalName; | 4734 return typedef_.canonicalName; |
4695 } | 4735 } |
4696 | 4736 |
4697 /// Annotation describing information which is not part of Dart semantics; in | 4737 /// Annotation describing information which is not part of Dart semantics; in |
4698 /// other words, if this information (or any information it refers to) changes, | 4738 /// other words, if this information (or any information it refers to) changes, |
4699 /// static analysis and runtime behavior of the library are unaffected. | 4739 /// static analysis and runtime behavior of the library are unaffected. |
4700 const informative = null; | 4740 const informative = null; |
OLD | NEW |