From 5e3cce44ae3001b03d6376e17503eabf0012e8e3 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 14 Nov 2024 10:20:37 -0800 Subject: [PATCH] Do not use SpecialClass to evaluate Enum or Interceptor --- lib/src/model/inheritable.dart | 14 +++++++++++++- lib/src/model/package_graph.dart | 17 ----------------- lib/src/special_elements.dart | 8 ++------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/lib/src/model/inheritable.dart b/lib/src/model/inheritable.dart index 2ad4a2f2ad..586c2768af 100644 --- a/lib/src/model/inheritable.dart +++ b/lib/src/model/inheritable.dart @@ -114,7 +114,19 @@ mixin Inheritable on ContainerMember { return super.computeCanonicalEnclosingContainer(); } - bool _isHiddenInterface(Container? c) => packageGraph.isHiddenInterface(c); + /// Whether [c] is a "hidden" interface. + /// + /// A hidden interface should never be considered the canonical enclosing + /// container of a container member. + /// + /// Add classes here if they are similar to the Dart SDK's 'Interceptor' class + /// in that they are to be ignored even when they are the implementers of + /// [Inheritable]s, and the class these inherit from should instead claim + /// implementation. + bool _isHiddenInterface(Container? c) => + c != null && + c.element.name == 'Interceptor' && + c.element.library?.name == '_interceptors'; /// A roughly ordered list of this element's enclosing container's inheritance /// chain. diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 06e58400b6..3eb5c10e20 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -706,23 +706,6 @@ class PackageGraph with CommentReferable, Nameable { ?.linkedName ?? 'Object'; - /// The set of [Class]es which should _not_ be considered the canonical - /// enclosing container of any container member. - /// - /// Add classes here if they are similar to Interceptor in that they are to be - /// ignored even when they are the implementers of [Inheritable]s, and the - /// class these inherit from should instead claim implementation. - late final Set _inheritThrough = { - if (specialClasses[SpecialClass.interceptor] case var interceptor?) - interceptor, - }; - - /// Whether [c] is a "hidden" interface. - /// - /// A hidden interface should never be considered the canonical enclosing - /// container of a container member. - bool isHiddenInterface(Container? c) => _inheritThrough.contains(c); - /// The set of [Class] objects that are similar to 'pragma' in that we should /// never count them as documentable annotations. late final Set _invisibleAnnotations = { diff --git a/lib/src/special_elements.dart b/lib/src/special_elements.dart index 63ffc0f3f5..55edcc41ad 100644 --- a/lib/src/special_elements.dart +++ b/lib/src/special_elements.dart @@ -19,11 +19,7 @@ import 'package:dartdoc/src/model/model.dart'; enum SpecialClass { object('Object', 'dart.core', 'dart:core'), - interceptor('Interceptor', '_interceptors', 'dart:_interceptors'), - - pragma('pragma', 'dart.core', 'dart:core'), - - enum_('Enum', 'dart.core', 'dart:core'); + pragma('pragma', 'dart.core', 'dart:core'); /// The package name in which these special [ModelElement]s can be found. static const String _packageName = 'Dart'; @@ -43,7 +39,7 @@ enum SpecialClass { /// Elements which must exist in the package graph when calling /// [SpecialClasses.new]. static List get _requiredSpecialClasses => - [SpecialClass.enum_, SpecialClass.object]; + [SpecialClass.object]; /// Returns the path of the Dart Library where this [ModelElement] is /// declared, or `null` if its URI does not denote a library in the specified