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

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 8a182b08d525d68bdd770951dd0acaf1aa0232fd..e088954010582e3a6d7524aebf6f231c106d8f87 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -620,6 +620,16 @@ class Class extends Indexable {
}
}
+ /**
+ * Makes sure that all methods with inherited equivalents have comments.
+ */
+ void ensureComments() {
+ inheritedMethods.forEach((qualifiedName, inheritedMethod) {
+ var method = methods[qualifiedName];
+ if (method != null) method.ensureCommentFor(inheritedMethod);
+ });
+ }
+
/**
* If a class extends a private superclass, find the closest public superclass
* of the private superclass.
@@ -669,6 +679,8 @@ class ClassGroup {
}
clazz.addInherited(parent);
});
+
+ clazz.ensureComments();
if (isError(mirror.qualifiedName)) {
errors[mirror.simpleName] = clazz;
@@ -780,6 +792,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;
@@ -788,11 +803,23 @@ class Method extends Indexable {
String qualifiedName, bool isPrivate, String owner) : super(name, comment,
qualifiedName, isPrivate, owner);
+ /**
+ * Makes sure that the method with an inherited equivalent have comments.
+ */
+ void ensureCommentFor(Method inheritedMethod) {
+ if (comment.isNotEmpty) return;
+ entityMap[inheritedMethod.owner].ensureComments();
+ comment = inheritedMethod.comment;
+ commentInheritedFrom = inheritedMethod.commentInheritedFrom == '' ?
+ inheritedMethod.qualifiedName : inheritedMethod.commentInheritedFrom;
+ }
+
/// Generates a map describing the [Method] object.
Map toMap() => {
'name': name,
'qualifiedname': qualifiedName,
'comment': comment,
+ 'commentfrom': commentInheritedFrom,
'static': isStatic.toString(),
'abstract': isAbstract.toString(),
'constant': isConst.toString(),
@@ -856,6 +883,23 @@ class MethodGroup {
'operators': recurseMap(operators),
'methods': recurseMap(regularMethods)
};
+
+ Method operator [](String qualifiedName) {
+ if (setters.containsKey(qualifiedName)) return setters[qualifiedName];
+ if (getters.containsKey(qualifiedName)) return getters[qualifiedName];
+ if (operators.containsKey(qualifiedName)) return operators[qualifiedName];
+ if (regularMethods.containsKey(qualifiedName)) {
+ return regularMethods[qualifiedName];
+ }
+ return null;
+ }
+
+ void forEach(void f(String key, Method value)) {
+ setters.forEach(f);
+ getters.forEach(f);
+ operators.forEach(f);
+ regularMethods.forEach(f);
+ }
}
/**
« 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