Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: pkg/docgen/lib/docgen.dart

Issue 19771019: add constant, abstract, and final to methods and variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 */ 300 */
301 Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap, 301 Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap,
302 bool includePrivate) { 302 bool includePrivate) {
303 var data = {}; 303 var data = {};
304 // TODO(janicejl): When map to map feature is created, replace the below with 304 // TODO(janicejl): When map to map feature is created, replace the below with
305 // a filter. Issue(#9590). 305 // a filter. Issue(#9590).
306 mirrorMap.forEach((String mirrorName, VariableMirror mirror) { 306 mirrorMap.forEach((String mirrorName, VariableMirror mirror) {
307 if (includePrivate || !mirror.isPrivate) { 307 if (includePrivate || !mirror.isPrivate) {
308 _currentMember = mirror; 308 _currentMember = mirror;
309 data[mirrorName] = new Variable(mirrorName, mirror.isFinal, 309 data[mirrorName] = new Variable(mirrorName, mirror.isFinal,
310 mirror.isStatic, mirror.type.qualifiedName, _getComment(mirror), 310 mirror.isStatic, mirror.isConst, mirror.type.qualifiedName,
311 _getAnnotations(mirror), mirror.qualifiedName); 311 _getComment(mirror), _getAnnotations(mirror), mirror.qualifiedName);
312 } 312 }
313 }); 313 });
314 return data; 314 return data;
315 } 315 }
316 316
317 /** 317 /**
318 * Returns a map of [Method] objects constructed from [mirrorMap]. 318 * Returns a map of [Method] objects constructed from [mirrorMap].
319 */ 319 */
320 Map<String, Map<String, Method>> _getMethods 320 Map<String, Map<String, Method>> _getMethods
321 (Map<String, MethodMirror> mirrorMap, bool includePrivate) { 321 (Map<String, MethodMirror> mirrorMap, bool includePrivate) {
322 322
323 var setters = {}; 323 var setters = {};
324 var getters = {}; 324 var getters = {};
325 var constructors = {}; 325 var constructors = {};
326 var operators = {}; 326 var operators = {};
327 var methods = {}; 327 var methods = {};
328 328
329 mirrorMap.forEach((String mirrorName, MethodMirror mirror) { 329 mirrorMap.forEach((String mirrorName, MethodMirror mirror) {
330 if (includePrivate || !mirror.isPrivate) { 330 if (includePrivate || !mirror.isPrivate) {
331 var method = new Method(mirrorName, mirror.isStatic, 331 var method = new Method(mirrorName, mirror.isStatic, mirror.isAbstract,
332 mirror.returnType.qualifiedName, _getComment(mirror), 332 mirror.isConstConstructor, mirror.returnType.qualifiedName,
333 _getParameters(mirror.parameters), _getAnnotations(mirror), 333 _getComment(mirror), _getParameters(mirror.parameters),
334 mirror.qualifiedName); 334 _getAnnotations(mirror), mirror.qualifiedName);
335 _currentMember = mirror; 335 _currentMember = mirror;
336 if (mirror.isSetter) { 336 if (mirror.isSetter) {
337 setters[mirrorName] = method; 337 setters[mirrorName] = method;
338 } else if (mirror.isGetter) { 338 } else if (mirror.isGetter) {
339 getters[mirrorName] = method; 339 getters[mirrorName] = method;
340 } else if (mirror.isConstructor) { 340 } else if (mirror.isConstructor) {
341 constructors[mirrorName] = method; 341 constructors[mirrorName] = method;
342 } else if (mirror.isOperator) { 342 } else if (mirror.isOperator) {
343 operators[mirrorName] = method; 343 operators[mirrorName] = method;
344 } else if (mirror.isRegularMethod) { 344 } else if (mirror.isRegularMethod) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 }; 570 };
571 } 571 }
572 572
573 /** 573 /**
574 * A class containing properties of a Dart variable. 574 * A class containing properties of a Dart variable.
575 */ 575 */
576 class Variable extends Indexable { 576 class Variable extends Indexable {
577 577
578 bool isFinal; 578 bool isFinal;
579 bool isStatic; 579 bool isStatic;
580 bool isConst;
580 String type; 581 String type;
581 582
582 /// List of the meta annotations on the variable. 583 /// List of the meta annotations on the variable.
583 List<String> annotations; 584 List<String> annotations;
584 585
585 Variable(String name, this.isFinal, this.isStatic, this.type, String comment, 586 Variable(String name, this.isFinal, this.isStatic, this.isConst, this.type,
586 this.annotations, String qualifiedName) : super(name, comment, 587 String comment, this.annotations, String qualifiedName) : super(name,
587 qualifiedName); 588 comment, qualifiedName);
588 589
589 /// Generates a map describing the [Variable] object. 590 /// Generates a map describing the [Variable] object.
590 Map toMap() => { 591 Map toMap() => {
591 'name': name, 592 'name': name,
592 'comment': comment, 593 'comment': comment,
593 'final': isFinal.toString(), 594 'final': isFinal.toString(),
594 'static': isStatic.toString(), 595 'static': isStatic.toString(),
596 'constant': isConst.toString(),
595 'type': type, 597 'type': type,
596 'annotations': new List.from(annotations) 598 'annotations': new List.from(annotations)
597 }; 599 };
598 } 600 }
599 601
600 /** 602 /**
601 * A class containing properties of a Dart method. 603 * A class containing properties of a Dart method.
602 */ 604 */
603 class Method extends Indexable { 605 class Method extends Indexable {
604 606
605 /// Parameters for this method. 607 /// Parameters for this method.
606 Map<String, Parameter> parameters; 608 Map<String, Parameter> parameters;
607 609
608 bool isStatic; 610 bool isStatic;
611 bool isAbstract;
612 bool isConst;
609 String returnType; 613 String returnType;
610 614
611 /// List of the meta annotations on the method. 615 /// List of the meta annotations on the method.
612 List<String> annotations; 616 List<String> annotations;
613 617
614 Method(String name, this.isStatic, this.returnType, String comment, 618 Method(String name, this.isStatic, this.isAbstract, this.isConst,
615 this.parameters, this.annotations, String qualifiedName) 619 this.returnType, String comment, this.parameters, this.annotations,
620 String qualifiedName)
616 : super(name, comment, qualifiedName); 621 : super(name, comment, qualifiedName);
617 622
618 /// Generates a map describing the [Method] object. 623 /// Generates a map describing the [Method] object.
619 Map toMap() => { 624 Map toMap() => {
620 'name': name, 625 'name': name,
621 'comment': comment, 626 'comment': comment,
622 'static': isStatic.toString(), 627 'static': isStatic.toString(),
628 'abstract': isAbstract.toString(),
629 'constant': isConst.toString(),
623 'return': returnType, 630 'return': returnType,
624 'parameters': recurseMap(parameters), 631 'parameters': recurseMap(parameters),
625 'annotations': new List.from(annotations) 632 'annotations': new List.from(annotations)
626 }; 633 };
627 } 634 }
628 635
629 /** 636 /**
630 * A class containing properties of a Dart method/function parameter. 637 * A class containing properties of a Dart method/function parameter.
631 */ 638 */
632 class Parameter { 639 class Parameter {
(...skipping 30 matching lines...) Expand all
663 String name; 670 String name;
664 String type; 671 String type;
665 672
666 Generic(this.name, this.type); 673 Generic(this.name, this.type);
667 674
668 Map toMap() => { 675 Map toMap() => {
669 'name': name, 676 'name': name,
670 'type': type 677 'type': type
671 }; 678 };
672 } 679 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698