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

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

Issue 21619003: Added inherited comments, and where they are inherited from. (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 72588c80027d366b598c35327a2fff0f97300f6c..56a64e159d17c9080ca81708d45d2e63f5754eed 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -620,6 +620,31 @@ class Class extends Indexable {
}
}
+ /**
+ * Makes sure that all methods with inherited equivalents have comments.
+ */
+ void ensureComments() {
+ inheritedMethods.keys.forEach((qualifiedName) {
+ var method = methods[qualifiedName];
Alan Knight 2013/08/02 18:32:22 Since you're actually using the value, this might
janicejl 2013/08/02 21:40:27 Done.
+ if (method != null) {
+ if (method.comment == "") {
Alan Knight 2013/08/02 18:32:22 I think this might also work better if you named t
janicejl 2013/08/02 21:40:27 Done.
+ var inheritedMethod = inheritedMethods[qualifiedName];
+ method.comment = inheritedMethod.comment;
+ if (method.comment != "") {
Alan Knight 2013/08/02 18:32:22 In fact, I think this could be rewritten to be muc
janicejl 2013/08/02 21:40:27 Done.
+ method.commentInheritedFrom =
+ inheritedMethod.commentInheritedFrom == "" ?
+ inheritedMethod.qualifiedName :
+ inheritedMethod.commentInheritedFrom;
+ } else {
+ entityMap[inheritedMethod.owner].ensureComments();
+ method.comment = inheritedMethod.comment;
+ method.commentInheritedFrom = inheritedMethod.commentInheritedFrom;
+ }
+ }
+ }
+ });
+ }
+
/// Generates a map describing the [Class] object.
Map toMap() => {
'name': name,
@@ -660,6 +685,8 @@ class ClassGroup {
}
clazz.addInherited(parent);
});
+
+ clazz.ensureComments();
if (isError(mirror.qualifiedName)) {
errors[mirror.simpleName] = clazz;
@@ -771,6 +798,9 @@ class Method extends Indexable {
bool isConst;
Type returnType;
+ /// Qualified name to state where the comment is inherited from.
+ String commentInheritedFrom = "";
+
/// List of the meta annotations on the method.
List<String> annotations;
@@ -784,6 +814,7 @@ class Method extends Indexable {
'name': name,
'qualifiedname': qualifiedName,
'comment': comment,
+ 'commentfrom': commentInheritedFrom,
'static': isStatic.toString(),
'abstract': isAbstract.toString(),
'constant': isConst.toString(),
@@ -847,6 +878,33 @@ class MethodGroup {
'operators': recurseMap(operators),
'methods': recurseMap(regularMethods)
};
+
+ Method operator [](String qualifiedName) {
+ var method = setters[qualifiedName];
Alan Knight 2013/08/02 18:32:22 I don't love the deep nesting. Redo as a loop over
janicejl 2013/08/02 21:40:27 Done.
+ if (method != null) return method;
+ else {
+ method = getters[qualifiedName];
+ if (method != null) return method;
+ else {
+ method = operators[qualifiedName];
+ if (method != null) return method;
+ else {
+ method = regularMethods[qualifiedName];
+ if (method != null) return method;
+ else return null;
+ }
+ }
+ }
+ }
+
+ Iterable<String> get keys {
Alan Knight 2013/08/02 18:32:22 => [setters, getters, operators, regularMethods].e
janicejl 2013/08/02 21:40:27 Done.
+ var qualifiedNames = [];
+ qualifiedNames.addAll(setters.keys);
+ qualifiedNames.addAll(getters.keys);
+ qualifiedNames.addAll(operators.keys);
+ qualifiedNames.addAll(regularMethods.keys);
+ return qualifiedNames;
+ }
}
/**
« 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