@@ -620,6 +620,16 @@ class Class extends Indexable {
620
620
}
621
621
}
622
622
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
+
623
633
/**
624
634
* If a class extends a private superclass, find the closest public superclass
625
635
* of the private superclass.
@@ -669,6 +679,8 @@ class ClassGroup {
669
679
}
670
680
clazz.addInherited (parent);
671
681
});
682
+
683
+ clazz.ensureComments ();
672
684
673
685
if (isError (mirror.qualifiedName)) {
674
686
errors[mirror.simpleName] = clazz;
@@ -780,6 +792,9 @@ class Method extends Indexable {
780
792
bool isConst;
781
793
Type returnType;
782
794
795
+ /// Qualified name to state where the comment is inherited from.
796
+ String commentInheritedFrom = "" ;
797
+
783
798
/// List of the meta annotations on the method.
784
799
List <String > annotations;
785
800
@@ -788,11 +803,23 @@ class Method extends Indexable {
788
803
String qualifiedName, bool isPrivate, String owner) : super (name, comment,
789
804
qualifiedName, isPrivate, owner);
790
805
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
+
791
817
/// Generates a map describing the [Method] object.
792
818
Map toMap () => {
793
819
'name' : name,
794
820
'qualifiedname' : qualifiedName,
795
821
'comment' : comment,
822
+ 'commentfrom' : commentInheritedFrom,
796
823
'static' : isStatic.toString (),
797
824
'abstract' : isAbstract.toString (),
798
825
'constant' : isConst.toString (),
@@ -856,6 +883,23 @@ class MethodGroup {
856
883
'operators' : recurseMap (operators),
857
884
'methods' : recurseMap (regularMethods)
858
885
};
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
+ }
859
903
}
860
904
861
905
/**
0 commit comments