OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * **docgen** is a tool for creating machine readable representations of Dart | 6 * **docgen** is a tool for creating machine readable representations of Dart |
7 * code metadata, including: classes, members, comments and annotations. | 7 * code metadata, including: classes, members, comments and annotations. |
8 * | 8 * |
9 * docgen is run on a `.dart` file or a directory containing `.dart` files. | 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. |
10 * | 10 * |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // results. | 231 // results. |
232 _writeToFile(filteredEntities.map((e) => e.qualifiedName).join('\n'), | 232 _writeToFile(filteredEntities.map((e) => e.qualifiedName).join('\n'), |
233 'index.txt', append: append); | 233 'index.txt', append: append); |
234 } | 234 } |
235 | 235 |
236 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) { | 236 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) { |
237 _currentLibrary = library; | 237 _currentLibrary = library; |
238 var result = new Library(library.qualifiedName, _commentToHtml(library), | 238 var result = new Library(library.qualifiedName, _commentToHtml(library), |
239 _variables(library.variables), | 239 _variables(library.variables), |
240 _methods(library.functions), | 240 _methods(library.functions), |
241 _classes(library.classes), _isPrivate(library)); | 241 _classes(library.classes), _isHidden(library)); |
242 logger.fine('Generated library for ${result.name}'); | 242 logger.fine('Generated library for ${result.name}'); |
243 return result; | 243 return result; |
244 } | 244 } |
245 | 245 |
246 void _writeIndexableToFile(Indexable result, bool outputToYaml) { | 246 void _writeIndexableToFile(Indexable result, bool outputToYaml) { |
247 if (outputToYaml) { | 247 if (outputToYaml) { |
248 _writeToFile(getYamlString(result.toMap()), '${result.qualifiedName}.yaml'); | 248 _writeToFile(getYamlString(result.toMap()), '${result.qualifiedName}.yaml'); |
249 } else { | 249 } else { |
250 _writeToFile(stringify(result.toMap()), '${result.qualifiedName}.json'); | 250 _writeToFile(stringify(result.toMap()), '${result.qualifiedName}.json'); |
251 } | 251 } |
(...skipping 10 matching lines...) Expand all Loading... |
262 bool _isLibraryPrivate(LibraryMirror mirror) { | 262 bool _isLibraryPrivate(LibraryMirror mirror) { |
263 if (mirror.simpleName.startsWith('_') || mirror.simpleName.contains('._')) { | 263 if (mirror.simpleName.startsWith('_') || mirror.simpleName.contains('._')) { |
264 return true; | 264 return true; |
265 } | 265 } |
266 return false; | 266 return false; |
267 } | 267 } |
268 | 268 |
269 /** | 269 /** |
270 * A declaration is private if itself is private, or the owner is private. | 270 * A declaration is private if itself is private, or the owner is private. |
271 */ | 271 */ |
272 bool _isPrivate(DeclarationMirror mirror) { | 272 // Issue(12202) - A declaration is public even if it's owner is private. |
| 273 bool _isHidden(DeclarationMirror mirror) { |
273 if (mirror is LibraryMirror) { | 274 if (mirror is LibraryMirror) { |
274 return _isLibraryPrivate(mirror); | 275 return _isLibraryPrivate(mirror); |
275 } else if (mirror.owner is LibraryMirror) { | 276 } else if (mirror.owner is LibraryMirror) { |
276 return (mirror.isPrivate || _isLibraryPrivate(mirror.owner)); | 277 return (mirror.isPrivate || _isLibraryPrivate(mirror.owner)); |
277 } else { | 278 } else { |
278 return (mirror.isPrivate || _isPrivate(mirror.owner)); | 279 return (mirror.isPrivate || _isHidden(mirror.owner)); |
279 } | 280 } |
280 } | 281 } |
281 | 282 |
282 bool _isVisible(Indexable item) { | 283 bool _isVisible(Indexable item) { |
283 return _includePrivate || !item.isPrivate; | 284 return _includePrivate || !item.isPrivate; |
284 } | 285 } |
285 | 286 |
286 /** | 287 /** |
287 * Returns a list of meta annotations assocated with a mirror. | 288 * Returns a list of meta annotations assocated with a mirror. |
288 */ | 289 */ |
289 List<String> _annotations(DeclarationMirror mirror) { | 290 List<String> _annotations(DeclarationMirror mirror) { |
290 var annotations = mirror.metadata.where((e) => | 291 var annotationMirrors = mirror.metadata.where((e) => |
291 e is dart2js.Dart2JsConstructedConstantMirror); | 292 e is dart2js.Dart2JsConstructedConstantMirror); |
292 return annotations.map((e) => e.type.qualifiedName).toList(); | 293 var annotations = []; |
| 294 annotationMirrors.forEach((annotation) { |
| 295 var parameterList = annotation.type.variables.values |
| 296 .where((e) => e.isFinal) |
| 297 .map((e) => annotation.getField(e.simpleName).reflectee) |
| 298 .where((e) => e != null) |
| 299 .toList(); |
| 300 annotations.add(new Annotation(annotation.type.qualifiedName, |
| 301 parameterList)); |
| 302 }); |
| 303 return annotations; |
293 } | 304 } |
294 | 305 |
295 /** | 306 /** |
296 * Returns any documentation comments associated with a mirror with | 307 * Returns any documentation comments associated with a mirror with |
297 * simple markdown converted to html. | 308 * simple markdown converted to html. |
298 */ | 309 */ |
299 String _commentToHtml(DeclarationMirror mirror) { | 310 String _commentToHtml(DeclarationMirror mirror) { |
300 String commentText; | 311 String commentText; |
301 mirror.metadata.forEach((metadata) { | 312 mirror.metadata.forEach((metadata) { |
302 if (metadata is CommentInstanceMirror) { | 313 if (metadata is CommentInstanceMirror) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 346 |
336 /** | 347 /** |
337 * Returns a map of [Variable] objects constructed from [mirrorMap]. | 348 * Returns a map of [Variable] objects constructed from [mirrorMap]. |
338 */ | 349 */ |
339 Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) { | 350 Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) { |
340 var data = {}; | 351 var data = {}; |
341 // TODO(janicejl): When map to map feature is created, replace the below with | 352 // TODO(janicejl): When map to map feature is created, replace the below with |
342 // a filter. Issue(#9590). | 353 // a filter. Issue(#9590). |
343 mirrorMap.forEach((String mirrorName, VariableMirror mirror) { | 354 mirrorMap.forEach((String mirrorName, VariableMirror mirror) { |
344 _currentMember = mirror; | 355 _currentMember = mirror; |
345 if (_includePrivate || !_isPrivate(mirror)) { | 356 if (_includePrivate || !_isHidden(mirror)) { |
346 entityMap[mirror.qualifiedName] = new Variable(mirrorName, mirror.isFinal, | 357 entityMap[mirror.qualifiedName] = new Variable(mirrorName, mirror.isFinal, |
347 mirror.isStatic, mirror.isConst, _type(mirror.type), | 358 mirror.isStatic, mirror.isConst, _type(mirror.type), |
348 _commentToHtml(mirror), _annotations(mirror), mirror.qualifiedName, | 359 _commentToHtml(mirror), _annotations(mirror), mirror.qualifiedName, |
349 _isPrivate(mirror), mirror.owner.qualifiedName); | 360 _isHidden(mirror), mirror.owner.qualifiedName); |
350 data[mirrorName] = entityMap[mirror.qualifiedName]; | 361 data[mirrorName] = entityMap[mirror.qualifiedName]; |
351 } | 362 } |
352 }); | 363 }); |
353 return data; | 364 return data; |
354 } | 365 } |
355 | 366 |
356 /** | 367 /** |
357 * Returns a map of [Method] objects constructed from [mirrorMap]. | 368 * Returns a map of [Method] objects constructed from [mirrorMap]. |
358 */ | 369 */ |
359 MethodGroup _methods(Map<String, MethodMirror> mirrorMap) { | 370 MethodGroup _methods(Map<String, MethodMirror> mirrorMap) { |
360 var group = new MethodGroup(); | 371 var group = new MethodGroup(); |
361 mirrorMap.forEach((String mirrorName, MethodMirror mirror) { | 372 mirrorMap.forEach((String mirrorName, MethodMirror mirror) { |
362 if (_includePrivate || !_isPrivate(mirror)) { | 373 if (_includePrivate || !_isHidden(mirror)) { |
363 group.addMethod(mirror); | 374 group.addMethod(mirror); |
364 } | 375 } |
365 }); | 376 }); |
366 return group; | 377 return group; |
367 } | 378 } |
368 | 379 |
369 /** | 380 /** |
370 * Returns the [Class] for the given [mirror] has already been created, and if | 381 * Returns the [Class] for the given [mirror] has already been created, and if |
371 * it does not exist, creates it. | 382 * it does not exist, creates it. |
372 */ | 383 */ |
373 Class _class(ClassMirror mirror) { | 384 Class _class(ClassMirror mirror) { |
374 var clazz = entityMap[mirror.qualifiedName]; | 385 var clazz = entityMap[mirror.qualifiedName]; |
375 if (clazz == null) { | 386 if (clazz == null) { |
376 var superclass = mirror.superclass != null ? | 387 var superclass = mirror.superclass != null ? |
377 _class(mirror.superclass) : null; | 388 _class(mirror.superclass) : null; |
378 var interfaces = | 389 var interfaces = |
379 mirror.superinterfaces.map((interface) => _class(interface)); | 390 mirror.superinterfaces.map((interface) => _class(interface)); |
380 clazz = new Class(mirror.simpleName, superclass, _commentToHtml(mirror), | 391 clazz = new Class(mirror.simpleName, superclass, _commentToHtml(mirror), |
381 interfaces.toList(), _variables(mirror.variables), | 392 interfaces.toList(), _variables(mirror.variables), |
382 _methods(mirror.methods), _annotations(mirror), _generics(mirror), | 393 _methods(mirror.methods), _annotations(mirror), _generics(mirror), |
383 mirror.qualifiedName, _isPrivate(mirror), mirror.owner.qualifiedName); | 394 mirror.qualifiedName, _isHidden(mirror), mirror.owner.qualifiedName); |
384 entityMap[mirror.qualifiedName] = clazz; | 395 entityMap[mirror.qualifiedName] = clazz; |
385 } | 396 } |
386 return clazz; | 397 return clazz; |
387 } | 398 } |
388 | 399 |
389 /** | 400 /** |
390 * Returns a map of [Class] objects constructed from [mirrorMap]. | 401 * Returns a map of [Class] objects constructed from [mirrorMap]. |
391 */ | 402 */ |
392 ClassGroup _classes(Map<String, ClassMirror> mirrorMap) { | 403 ClassGroup _classes(Map<String, ClassMirror> mirrorMap) { |
393 var group = new ClassGroup(); | 404 var group = new ClassGroup(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 if (_isVisible(superclass)) return superclass.qualifiedName; | 640 if (_isVisible(superclass)) return superclass.qualifiedName; |
630 return superclass.validSuperclass(); | 641 return superclass.validSuperclass(); |
631 } | 642 } |
632 | 643 |
633 /// Generates a map describing the [Class] object. | 644 /// Generates a map describing the [Class] object. |
634 Map toMap() => { | 645 Map toMap() => { |
635 'name': name, | 646 'name': name, |
636 'qualifiedname': qualifiedName, | 647 'qualifiedname': qualifiedName, |
637 'comment': comment, | 648 'comment': comment, |
638 'superclass': validSuperclass(), | 649 'superclass': validSuperclass(), |
639 'implements': new List.from(interfaces.where(_isVisible) | 650 'implements': interfaces.where(_isVisible) |
640 .map((e) => e.qualifiedName)), | 651 .map((e) => e.qualifiedName).toList(), |
641 'subclass': new List.from(subclasses), | 652 'subclass': subclasses, |
642 'variables': recurseMap(variables), | 653 'variables': recurseMap(variables), |
643 'inheritedvariables': recurseMap(inheritedVariables), | 654 'inheritedvariables': recurseMap(inheritedVariables), |
644 'methods': methods.toMap(), | 655 'methods': methods.toMap(), |
645 'inheritedmethods': inheritedMethods.toMap(), | 656 'inheritedmethods': inheritedMethods.toMap(), |
646 'annotations': new List.from(annotations), | 657 'annotations': annotations.map((a) => a.toMap()).toList(), |
647 'generics': recurseMap(generics) | 658 'generics': recurseMap(generics) |
648 }; | 659 }; |
649 } | 660 } |
650 | 661 |
651 /** | 662 /** |
652 * A container to categorize classes into the following groups: abstract | 663 * A container to categorize classes into the following groups: abstract |
653 * classes, regular classes, typedefs, and errors. | 664 * classes, regular classes, typedefs, and errors. |
654 */ | 665 */ |
655 class ClassGroup { | 666 class ClassGroup { |
656 Map<String, Class> abstractClasses = {}; | 667 Map<String, Class> abstractClasses = {}; |
(...skipping 13 matching lines...) Expand all Loading... |
670 clazz.addInherited(parent); | 681 clazz.addInherited(parent); |
671 }); | 682 }); |
672 | 683 |
673 if (isError(mirror.qualifiedName)) { | 684 if (isError(mirror.qualifiedName)) { |
674 errors[mirror.simpleName] = clazz; | 685 errors[mirror.simpleName] = clazz; |
675 } else if (mirror.isTypedef) { | 686 } else if (mirror.isTypedef) { |
676 if (_includePrivate || !mirror.isPrivate) { | 687 if (_includePrivate || !mirror.isPrivate) { |
677 entityMap[mirror.qualifiedName] = new Typedef(mirror.simpleName, | 688 entityMap[mirror.qualifiedName] = new Typedef(mirror.simpleName, |
678 mirror.value.returnType.qualifiedName, _commentToHtml(mirror), | 689 mirror.value.returnType.qualifiedName, _commentToHtml(mirror), |
679 _generics(mirror), _parameters(mirror.value.parameters), | 690 _generics(mirror), _parameters(mirror.value.parameters), |
680 _annotations(mirror), mirror.qualifiedName, _isPrivate(mirror), | 691 _annotations(mirror), mirror.qualifiedName, _isHidden(mirror), |
681 mirror.owner.qualifiedName); | 692 mirror.owner.qualifiedName); |
682 typedefs[mirror.simpleName] = entityMap[mirror.qualifiedName]; | 693 typedefs[mirror.simpleName] = entityMap[mirror.qualifiedName]; |
683 } | 694 } |
684 } else if (mirror.isAbstract) { | 695 } else if (mirror.isAbstract) { |
685 abstractClasses[mirror.simpleName] = clazz; | 696 abstractClasses[mirror.simpleName] = clazz; |
686 } else if (mirror.isClass) { | 697 } else if (mirror.isClass) { |
687 regularClasses[mirror.simpleName] = clazz; | 698 regularClasses[mirror.simpleName] = clazz; |
688 } else { | 699 } else { |
689 throw new ArgumentError('${mirror.simpleName} - no class type match. '); | 700 throw new ArgumentError('${mirror.simpleName} - no class type match. '); |
690 } | 701 } |
691 } | 702 } |
692 | 703 |
693 /** | 704 /** |
694 * Checks if the given name is a key for any of the Class Maps. | 705 * Checks if the given name is a key for any of the Class Maps. |
695 */ | 706 */ |
696 bool containsKey(String name) { | 707 bool containsKey(String name) { |
697 return abstractClasses.containsKey(name) || | 708 return abstractClasses.containsKey(name) || |
698 regularClasses.containsKey(name) || | 709 regularClasses.containsKey(name) || |
699 errors.containsKey(name); | 710 errors.containsKey(name); |
700 } | 711 } |
701 | 712 |
702 Map toMap() => { | 713 Map toMap() => { |
703 'abstract': new List.from(abstractClasses.values | 714 'abstract': abstractClasses.values.where(_isVisible) |
704 .where(_isVisible).map((e) => e.qualifiedName)), | 715 .map((e) => e.qualifiedName).toList(), |
705 'class': new List.from(regularClasses.values | 716 'class': regularClasses.values.where(_isVisible) |
706 .where(_isVisible).map((e) => e.qualifiedName)), | 717 .map((e) => e.qualifiedName).toList(), |
707 'typedef': recurseMap(typedefs), | 718 'typedef': recurseMap(typedefs), |
708 'error': new List.from(errors.values | 719 'error': errors.values.where(_isVisible) |
709 .where(_isVisible).map((e) => e.qualifiedName)) | 720 .map((e) => e.qualifiedName).toList() |
710 }; | 721 }; |
711 } | 722 } |
712 | 723 |
713 class Typedef extends Indexable { | 724 class Typedef extends Indexable { |
714 String returnType; | 725 String returnType; |
715 | 726 |
716 Map<String, Parameter> parameters; | 727 Map<String, Parameter> parameters; |
717 | 728 |
718 /// Generic information about the typedef. | 729 /// Generic information about the typedef. |
719 Map<String, Generic> generics; | 730 Map<String, Generic> generics; |
720 | 731 |
721 /// List of the meta annotations on the typedef. | 732 /// List of the meta annotations on the typedef. |
722 List<String> annotations; | 733 List<String> annotations; |
723 | 734 |
724 Typedef(String name, this.returnType, String comment, this.generics, | 735 Typedef(String name, this.returnType, String comment, this.generics, |
725 this.parameters, this.annotations, | 736 this.parameters, this.annotations, |
726 String qualifiedName, bool isPrivate, String owner) : super(name, comment, | 737 String qualifiedName, bool isPrivate, String owner) : super(name, comment, |
727 qualifiedName, isPrivate, owner) {} | 738 qualifiedName, isPrivate, owner) {} |
728 | 739 |
729 Map toMap() => { | 740 Map toMap() => { |
730 'name': name, | 741 'name': name, |
731 'qualifiedname': qualifiedName, | 742 'qualifiedname': qualifiedName, |
732 'comment': comment, | 743 'comment': comment, |
733 'return': returnType, | 744 'return': returnType, |
734 'parameters': recurseMap(parameters), | 745 'parameters': recurseMap(parameters), |
735 'annotations': new List.from(annotations), | 746 'annotations': annotations.map((a) => a.toMap()).toList(), |
736 'generics': recurseMap(generics) | 747 'generics': recurseMap(generics) |
737 }; | 748 }; |
738 } | 749 } |
739 | 750 |
740 /** | 751 /** |
741 * A class containing properties of a Dart variable. | 752 * A class containing properties of a Dart variable. |
742 */ | 753 */ |
743 class Variable extends Indexable { | 754 class Variable extends Indexable { |
744 | 755 |
745 bool isFinal; | 756 bool isFinal; |
(...skipping 10 matching lines...) Expand all Loading... |
756 | 767 |
757 /// Generates a map describing the [Variable] object. | 768 /// Generates a map describing the [Variable] object. |
758 Map toMap() => { | 769 Map toMap() => { |
759 'name': name, | 770 'name': name, |
760 'qualifiedname': qualifiedName, | 771 'qualifiedname': qualifiedName, |
761 'comment': comment, | 772 'comment': comment, |
762 'final': isFinal.toString(), | 773 'final': isFinal.toString(), |
763 'static': isStatic.toString(), | 774 'static': isStatic.toString(), |
764 'constant': isConst.toString(), | 775 'constant': isConst.toString(), |
765 'type': new List.filled(1, type.toMap()), | 776 'type': new List.filled(1, type.toMap()), |
766 'annotations': new List.from(annotations) | 777 'annotations': annotations.map((a) => a.toMap()).toList() |
767 }; | 778 }; |
768 } | 779 } |
769 | 780 |
770 /** | 781 /** |
771 * A class containing properties of a Dart method. | 782 * A class containing properties of a Dart method. |
772 */ | 783 */ |
773 class Method extends Indexable { | 784 class Method extends Indexable { |
774 | 785 |
775 /// Parameters for this method. | 786 /// Parameters for this method. |
776 Map<String, Parameter> parameters; | 787 Map<String, Parameter> parameters; |
(...skipping 14 matching lines...) Expand all Loading... |
791 /// Generates a map describing the [Method] object. | 802 /// Generates a map describing the [Method] object. |
792 Map toMap() => { | 803 Map toMap() => { |
793 'name': name, | 804 'name': name, |
794 'qualifiedname': qualifiedName, | 805 'qualifiedname': qualifiedName, |
795 'comment': comment, | 806 'comment': comment, |
796 'static': isStatic.toString(), | 807 'static': isStatic.toString(), |
797 'abstract': isAbstract.toString(), | 808 'abstract': isAbstract.toString(), |
798 'constant': isConst.toString(), | 809 'constant': isConst.toString(), |
799 'return': new List.filled(1, returnType.toMap()), | 810 'return': new List.filled(1, returnType.toMap()), |
800 'parameters': recurseMap(parameters), | 811 'parameters': recurseMap(parameters), |
801 'annotations': new List.from(annotations) | 812 'annotations': annotations.map((a) => a.toMap()).toList() |
802 }; | 813 }; |
803 } | 814 } |
804 | 815 |
805 /** | 816 /** |
806 * A container to categorize methods into the following groups: setters, | 817 * A container to categorize methods into the following groups: setters, |
807 * getters, constructors, operators, regular methods. | 818 * getters, constructors, operators, regular methods. |
808 */ | 819 */ |
809 class MethodGroup { | 820 class MethodGroup { |
810 Map<String, Method> setters = {}; | 821 Map<String, Method> setters = {}; |
811 Map<String, Method> getters = {}; | 822 Map<String, Method> getters = {}; |
812 Map<String, Method> constructors = {}; | 823 Map<String, Method> constructors = {}; |
813 Map<String, Method> operators = {}; | 824 Map<String, Method> operators = {}; |
814 Map<String, Method> regularMethods = {}; | 825 Map<String, Method> regularMethods = {}; |
815 | 826 |
816 void addMethod(MethodMirror mirror) { | 827 void addMethod(MethodMirror mirror) { |
817 var method = new Method(mirror.simpleName, mirror.isStatic, | 828 var method = new Method(mirror.simpleName, mirror.isStatic, |
818 mirror.isAbstract, mirror.isConstConstructor, _type(mirror.returnType), | 829 mirror.isAbstract, mirror.isConstConstructor, _type(mirror.returnType), |
819 _commentToHtml(mirror), _parameters(mirror.parameters), | 830 _commentToHtml(mirror), _parameters(mirror.parameters), |
820 _annotations(mirror), mirror.qualifiedName, _isPrivate(mirror), | 831 _annotations(mirror), mirror.qualifiedName, _isHidden(mirror), |
821 mirror.owner.qualifiedName); | 832 mirror.owner.qualifiedName); |
822 entityMap[mirror.qualifiedName] = method; | 833 entityMap[mirror.qualifiedName] = method; |
823 _currentMember = mirror; | 834 _currentMember = mirror; |
824 if (mirror.isSetter) { | 835 if (mirror.isSetter) { |
825 setters[mirror.simpleName] = method; | 836 setters[mirror.simpleName] = method; |
826 } else if (mirror.isGetter) { | 837 } else if (mirror.isGetter) { |
827 getters[mirror.simpleName] = method; | 838 getters[mirror.simpleName] = method; |
828 } else if (mirror.isConstructor) { | 839 } else if (mirror.isConstructor) { |
829 constructors[mirror.simpleName] = method; | 840 constructors[mirror.simpleName] = method; |
830 } else if (mirror.isOperator) { | 841 } else if (mirror.isOperator) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 this.type, this.defaultValue, this.annotations); | 888 this.type, this.defaultValue, this.annotations); |
878 | 889 |
879 /// Generates a map describing the [Parameter] object. | 890 /// Generates a map describing the [Parameter] object. |
880 Map toMap() => { | 891 Map toMap() => { |
881 'name': name, | 892 'name': name, |
882 'optional': isOptional.toString(), | 893 'optional': isOptional.toString(), |
883 'named': isNamed.toString(), | 894 'named': isNamed.toString(), |
884 'default': hasDefaultValue.toString(), | 895 'default': hasDefaultValue.toString(), |
885 'type': new List.filled(1, type.toMap()), | 896 'type': new List.filled(1, type.toMap()), |
886 'value': defaultValue, | 897 'value': defaultValue, |
887 'annotations': new List.from(annotations) | 898 'annotations': annotations.map((a) => a.toMap()).toList() |
888 }; | 899 }; |
889 } | 900 } |
890 | 901 |
891 /** | 902 /** |
892 * A class containing properties of a Generic. | 903 * A class containing properties of a Generic. |
893 */ | 904 */ |
894 class Generic { | 905 class Generic { |
895 String name; | 906 String name; |
896 String type; | 907 String type; |
897 | 908 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 * "inner" : | 945 * "inner" : |
935 */ | 946 */ |
936 class Type { | 947 class Type { |
937 String outer; | 948 String outer; |
938 List<Type> inner; | 949 List<Type> inner; |
939 | 950 |
940 Type(this.outer, this.inner); | 951 Type(this.outer, this.inner); |
941 | 952 |
942 Map toMap() => { | 953 Map toMap() => { |
943 'outer': outer, | 954 'outer': outer, |
944 'inner': new List.from(inner.map((e) => e.toMap())) | 955 'inner': inner.map((e) => e.toMap()).toList() |
| 956 }; |
| 957 } |
| 958 |
| 959 /** |
| 960 * Holds the name of the annotation, and its parameters. |
| 961 */ |
| 962 class Annotation { |
| 963 String qualifiedName; |
| 964 List<String> parameters; |
| 965 |
| 966 Annotation(this.qualifiedName, this.parameters); |
| 967 |
| 968 Map toMap() => { |
| 969 'name': qualifiedName, |
| 970 'parameters': parameters |
945 }; | 971 }; |
946 } | 972 } |
OLD | NEW |