From 1619439e0b270e1193c94e378af63f90f5f41711 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Fri, 19 Dec 2025 17:57:46 -0800 Subject: [PATCH] Simplify DocumentationComment.documentationFrom --- lib/src/model/documentation_comment.dart | 18 +----------------- lib/src/model/inheritable.dart | 11 +++++++++++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/src/model/documentation_comment.dart b/lib/src/model/documentation_comment.dart index 00941cd160..e86d4883cd 100644 --- a/lib/src/model/documentation_comment.dart +++ b/lib/src/model/documentation_comment.dart @@ -10,7 +10,6 @@ import 'package:args/args.dart'; import 'package:crypto/crypto.dart' as crypto; import 'package:dartdoc/src/model/documentable.dart'; import 'package:dartdoc/src/model/documentation.dart'; -import 'package:dartdoc/src/model/inheritable.dart'; import 'package:dartdoc/src/model/locatable.dart'; import 'package:dartdoc/src/model/model_element.dart'; import 'package:dartdoc/src/model/source_code_mixin.dart'; @@ -43,23 +42,8 @@ mixin DocumentationComment @override Element get element; - List? _documentationFrom; - @override - List get documentationFrom => - _documentationFrom ??= () { - final self = this; - if (self is! Inheritable) { - return [this]; - } - if (!hasDocumentationComment && self.overriddenElement != null) { - return self.overriddenElement!.documentationFrom; - } else if (self.isInherited) { - return packageGraph.getModelForElement(element).documentationFrom; - } else { - return [this]; - } - }(); + List get documentationFrom => [this]; @override late final String documentationAsHtml = diff --git a/lib/src/model/inheritable.dart b/lib/src/model/inheritable.dart index 54937f6263..d88213cbed 100644 --- a/lib/src/model/inheritable.dart +++ b/lib/src/model/inheritable.dart @@ -36,6 +36,17 @@ mixin Inheritable on ContainerMember { if (isCovariant) Attribute.covariant, }; + @override + List get documentationFrom { + if (!hasDocumentationComment && overriddenElement != null) { + return overriddenElement!.documentationFrom; + } else if (isInherited) { + return packageGraph.getModelForElement(element).documentationFrom; + } else { + return super.documentationFrom; + } + } + @override Library? get canonicalLibrary => canonicalEnclosingContainer?.canonicalLibrary;