commentRefs property

Map<String, ModelCommentReference> commentRefs
override

A map of ModelCommentReference.codeRef to ModelCommentReference. This map deduplicates comment references as all identical reference strings inside a single documentation comment will point to the same place, so it should not be used to count exactly how many references there are.

Implementation

@override
Map<String, ModelCommentReference> get commentRefs {
  if (_commentRefs == null) {
    _commentRefs = {};
    for (var from in documentationFrom) {
      var checkReferences = <ModelElement>[from];
      if (from is Accessor) {
        checkReferences.add(from.enclosingCombo);
      }
      for (var e in checkReferences) {
        // Some elements don't have modelNodes or aren't traversed by
        // the element visitor, or both.
        assert(e is Parameter || e.modelNode != null);
        _commentRefs.addAll({
          for (var r in e.modelNode?.commentRefs ?? <ModelCommentReference>[])
            r.codeRef: r
        });
      }
    }
  }
  return _commentRefs;
}