@@ -620,6 +620,16 @@ class Class extends Indexable {
620620 }
621621 }
622622
623+ /**
624+ * Makes sure that all methods with inherited equivalents have comments.
625+ */
626+ void ensureComments () {
627+ inheritedMethods.forEach ((qualifiedName, inheritedMethod) {
628+ var method = methods[qualifiedName];
629+ if (method != null ) method.ensureCommentFor (inheritedMethod);
630+ });
631+ }
632+
623633 /**
624634 * If a class extends a private superclass, find the closest public superclass
625635 * of the private superclass.
@@ -669,6 +679,8 @@ class ClassGroup {
669679 }
670680 clazz.addInherited (parent);
671681 });
682+
683+ clazz.ensureComments ();
672684
673685 if (isError (mirror.qualifiedName)) {
674686 errors[mirror.simpleName] = clazz;
@@ -780,6 +792,9 @@ class Method extends Indexable {
780792 bool isConst;
781793 Type returnType;
782794
795+ /// Qualified name to state where the comment is inherited from.
796+ String commentInheritedFrom = "" ;
797+
783798 /// List of the meta annotations on the method.
784799 List <String > annotations;
785800
@@ -788,11 +803,23 @@ class Method extends Indexable {
788803 String qualifiedName, bool isPrivate, String owner) : super (name, comment,
789804 qualifiedName, isPrivate, owner);
790805
806+ /**
807+ * Makes sure that the method with an inherited equivalent have comments.
808+ */
809+ void ensureCommentFor (Method inheritedMethod) {
810+ if (comment.isNotEmpty) return ;
811+ entityMap[inheritedMethod.owner].ensureComments ();
812+ comment = inheritedMethod.comment;
813+ commentInheritedFrom = inheritedMethod.commentInheritedFrom == '' ?
814+ inheritedMethod.qualifiedName : inheritedMethod.commentInheritedFrom;
815+ }
816+
791817 /// Generates a map describing the [Method] object.
792818 Map toMap () => {
793819 'name' : name,
794820 'qualifiedname' : qualifiedName,
795821 'comment' : comment,
822+ 'commentfrom' : commentInheritedFrom,
796823 'static' : isStatic.toString (),
797824 'abstract' : isAbstract.toString (),
798825 'constant' : isConst.toString (),
@@ -856,6 +883,23 @@ class MethodGroup {
856883 'operators' : recurseMap (operators),
857884 'methods' : recurseMap (regularMethods)
858885 };
886+
887+ Method operator [](String qualifiedName) {
888+ if (setters.containsKey (qualifiedName)) return setters[qualifiedName];
889+ if (getters.containsKey (qualifiedName)) return getters[qualifiedName];
890+ if (operators.containsKey (qualifiedName)) return operators[qualifiedName];
891+ if (regularMethods.containsKey (qualifiedName)) {
892+ return regularMethods[qualifiedName];
893+ }
894+ return null ;
895+ }
896+
897+ void forEach (void f (String key, Method value)) {
898+ setters.forEach (f);
899+ getters.forEach (f);
900+ operators.forEach (f);
901+ regularMethods.forEach (f);
902+ }
859903}
860904
861905/**
0 commit comments