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

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

Issue 63483002: Fix some users of removed mirror API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | pkg/polymer/lib/src/declaration.dart » ('j') | 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 /// **docgen** is a tool for creating machine readable representations of Dart 5 /// **docgen** is a tool for creating machine readable representations of Dart
6 /// code metadata, including: classes, members, comments and annotations. 6 /// code metadata, including: classes, members, comments and annotations.
7 /// 7 ///
8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files.
9 /// 9 ///
10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR]
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 filteredEntities.map((e) => e.qualifiedName), 358 filteredEntities.map((e) => e.qualifiedName),
359 filteredEntities.map((e) => e.typeName)); 359 filteredEntities.map((e) => e.typeName));
360 if (append) { 360 if (append) {
361 var previousIndex = 361 var previousIndex =
362 JSON.decode(new File('docs/index.json').readAsStringSync()); 362 JSON.decode(new File('docs/index.json').readAsStringSync());
363 index.addAll(previousIndex); 363 index.addAll(previousIndex);
364 } 364 }
365 _writeToFile(JSON.encode(index), 'index.json'); 365 _writeToFile(JSON.encode(index), 'index.json');
366 } 366 }
367 367
368 _filterMap(map, predicate) {
369 var result = new Map();
370 map.forEach((key, value) {
371 if (predicate(value)) result[key] = value;
372 });
373 return result;
374 }
375
368 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) { 376 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) {
369 _currentLibrary = library; 377 _currentLibrary = library;
370 var result = new Library(docName(library), _commentToHtml(library), 378 var result = new Library(
371 _variables(library.variables), 379 docName(library),
372 _methods(library.functions), 380 _commentToHtml(library),
373 _classes(library.classes), _isHidden(library)); 381 _variables(_filterMap(library.declarations, (d) => d is VariableMirror)),
382 _methods(_filterMap(library.declarations, (d) => d is MethodMirror)),
383 _classes(_filterMap(library.declarations, (d) => d is ClassMirror)),
384 _isHidden(library));
374 _findPackage(result, library); 385 _findPackage(result, library);
375 logger.fine('Generated library for ${result.name}'); 386 logger.fine('Generated library for ${result.name}');
376 return result; 387 return result;
377 } 388 }
378 389
379 void _writeIndexableToFile(Indexable result, bool outputToYaml) { 390 void _writeIndexableToFile(Indexable result, bool outputToYaml) {
380 var outputFile = result.fileName; 391 var outputFile = result.fileName;
381 var output; 392 var output;
382 if (outputToYaml) { 393 if (outputToYaml) {
383 output = getYamlString(result.toMap()); 394 output = getYamlString(result.toMap());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 /// Returns the [Class] for the given [mirror] has already been created, and if 661 /// Returns the [Class] for the given [mirror] has already been created, and if
651 /// it does not exist, creates it. 662 /// it does not exist, creates it.
652 Class _class(ClassMirror mirror) { 663 Class _class(ClassMirror mirror) {
653 var clazz = entityMap[docName(mirror)]; 664 var clazz = entityMap[docName(mirror)];
654 if (clazz == null) { 665 if (clazz == null) {
655 var superclass = mirror.superclass != null ? 666 var superclass = mirror.superclass != null ?
656 _class(mirror.superclass) : null; 667 _class(mirror.superclass) : null;
657 var interfaces = 668 var interfaces =
658 mirror.superinterfaces.map((interface) => _class(interface)); 669 mirror.superinterfaces.map((interface) => _class(interface));
659 clazz = new Class(mirror.simpleName, superclass, _commentToHtml(mirror), 670 clazz = new Class(mirror.simpleName, superclass, _commentToHtml(mirror),
660 interfaces.toList(), _variables(mirror.variables), 671 interfaces.toList(),
661 _methods(mirror.methods), _annotations(mirror), _generics(mirror), 672 _variables(_filterMap(mirror.declarations, (d) => d is VariableMirror)),
673 _methods(_filterMap(mirror.declarations,
674 (d) => d is MethodMirror && !d.isConstructor)),
675 _annotations(mirror), _generics(mirror),
662 docName(mirror), _isHidden(mirror), docName(mirror.owner), 676 docName(mirror), _isHidden(mirror), docName(mirror.owner),
663 mirror.isAbstract); 677 mirror.isAbstract);
664 if (superclass != null) clazz.addInherited(superclass); 678 if (superclass != null) clazz.addInherited(superclass);
665 interfaces.forEach((interface) => clazz.addInherited(interface)); 679 interfaces.forEach((interface) => clazz.addInherited(interface));
666 entityMap[docName(mirror)] = clazz; 680 entityMap[docName(mirror)] = clazz;
667 } 681 }
668 return clazz; 682 return clazz;
669 } 683 }
670 684
671 /// Returns a map of [Class] objects constructed from [mirrorMap]. 685 /// Returns a map of [Class] objects constructed from [mirrorMap].
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 String docName(DeclarationMirror m) { 1339 String docName(DeclarationMirror m) {
1326 if (m is LibraryMirror) { 1340 if (m is LibraryMirror) {
1327 return (m as LibraryMirror).qualifiedName.replaceAll('.','-'); 1341 return (m as LibraryMirror).qualifiedName.replaceAll('.','-');
1328 } 1342 }
1329 var owner = m.owner; 1343 var owner = m.owner;
1330 if (owner == null) return m.qualifiedName; 1344 if (owner == null) return m.qualifiedName;
1331 // For the unnamed constructor we just return the class name. 1345 // For the unnamed constructor we just return the class name.
1332 if (m.simpleName == '') return docName(owner); 1346 if (m.simpleName == '') return docName(owner);
1333 return docName(owner) + '.' + m.simpleName; 1347 return docName(owner) + '.' + m.simpleName;
1334 } 1348 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/lib/src/declaration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698