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

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 19564013: added generic information (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/docgen.dart
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
index 5d0b391ebb710d0dd49095aca7374987ce53e310..415102a25614d80fb95d902ea0bceabdb8920941 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -368,7 +368,7 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap,
var typedefs = {};
var errors = {};
- mirrorMap.forEach((String mirrorName, ClassMirror mirror) {
+ mirrorMap.forEach((String mirrorName, ClassMirror mirror) {
if (includePrivate || !mirror.isPrivate) {
var superclass = (mirror.superclass != null) ?
mirror.superclass.qualifiedName : '';
@@ -377,7 +377,7 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap,
var clazz = new Class(mirrorName, superclass, _getComment(mirror),
interfaces.toList(), _getVariables(mirror.variables, includePrivate),
_getMethods(mirror.methods, includePrivate),
- _getAnnotations(mirror), mirror.qualifiedName);
+ _getAnnotations(mirror), _getGenerics(mirror), mirror.qualifiedName);
_currentClass = mirror;
if (isError(mirror.qualifiedName)) {
@@ -417,6 +417,15 @@ Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) {
}
/**
+ * Returns a map of [Generic] objects constructed from the class mirror.
+ */
+Map<String, Generic> _getGenerics(ClassMirror mirror) {
+ return new Map.fromIterable(mirror.typeVariables,
+ key: (e) => e.toString(),
+ value: (e) => new Generic(e.toString(), e.upperBound.qualifiedName));
+}
+
+/**
* Writes text to a file in the 'docs' directory.
*/
void _writeToFile(String text, String filename) {
@@ -515,6 +524,9 @@ class Class extends Indexable {
/// Methods in the class.
Map<String, Map<String, Method>> methods;
+ /// Generic infomation about the class.
+ Map<String, Generic> generics;
+
String name;
String superclass;
@@ -522,7 +534,7 @@ class Class extends Indexable {
List<String> annotations;
Class(this.name, this.superclass, this.comment, this.interfaces,
- this.variables, this.methods, this.annotations,
+ this.variables, this.methods, this.annotations, this.generics,
String qualifiedName) : super(qualifiedName) {}
/// Generates a map describing the [Class] object.
@@ -535,6 +547,7 @@ class Class extends Indexable {
classMap['variables'] = recurseMap(variables);
classMap['methods'] = recurseMap(methods);
classMap['annotations'] = new List.from(annotations);
+ classMap['generics'] = recurseMap(generics);
return classMap;
}
}
@@ -637,3 +650,20 @@ class Parameter {
return parameterMap;
}
}
+
+/**
+ * A class containing properties of a Generic.
+ */
+class Generic {
+ String name;
+ String type;
+
+ Generic(this.name, this.type);
+
+ Map toMap() {
+ return {
+ 'name': name,
+ 'type': type
+ };
+ }
+}
« 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