Skip to content

Commit 6bbd3d7

Browse files
authored
Do not use SpecialClass to evaluate Enum or Interceptor (#3928)
1 parent dcc239a commit 6bbd3d7

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

lib/src/model/inheritable.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,19 @@ mixin Inheritable on ContainerMember {
114114
return super.computeCanonicalEnclosingContainer();
115115
}
116116

117-
bool _isHiddenInterface(Container? c) => packageGraph.isHiddenInterface(c);
117+
/// Whether [c] is a "hidden" interface.
118+
///
119+
/// A hidden interface should never be considered the canonical enclosing
120+
/// container of a container member.
121+
///
122+
/// Add classes here if they are similar to the Dart SDK's 'Interceptor' class
123+
/// in that they are to be ignored even when they are the implementers of
124+
/// [Inheritable]s, and the class these inherit from should instead claim
125+
/// implementation.
126+
bool _isHiddenInterface(Container? c) =>
127+
c != null &&
128+
c.element.name == 'Interceptor' &&
129+
c.element.library?.name == '_interceptors';
118130

119131
/// A roughly ordered list of this element's enclosing container's inheritance
120132
/// chain.

lib/src/model/package_graph.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -706,23 +706,6 @@ class PackageGraph with CommentReferable, Nameable {
706706
?.linkedName ??
707707
'Object';
708708

709-
/// The set of [Class]es which should _not_ be considered the canonical
710-
/// enclosing container of any container member.
711-
///
712-
/// Add classes here if they are similar to Interceptor in that they are to be
713-
/// ignored even when they are the implementers of [Inheritable]s, and the
714-
/// class these inherit from should instead claim implementation.
715-
late final Set<Class> _inheritThrough = {
716-
if (specialClasses[SpecialClass.interceptor] case var interceptor?)
717-
interceptor,
718-
};
719-
720-
/// Whether [c] is a "hidden" interface.
721-
///
722-
/// A hidden interface should never be considered the canonical enclosing
723-
/// container of a container member.
724-
bool isHiddenInterface(Container? c) => _inheritThrough.contains(c);
725-
726709
/// The set of [Class] objects that are similar to 'pragma' in that we should
727710
/// never count them as documentable annotations.
728711
late final Set<Class> _invisibleAnnotations = {

lib/src/special_elements.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ import 'package:dartdoc/src/model/model.dart';
1919
enum SpecialClass {
2020
object('Object', 'dart.core', 'dart:core'),
2121

22-
interceptor('Interceptor', '_interceptors', 'dart:_interceptors'),
23-
24-
pragma('pragma', 'dart.core', 'dart:core'),
25-
26-
enum_('Enum', 'dart.core', 'dart:core');
22+
pragma('pragma', 'dart.core', 'dart:core');
2723

2824
/// The package name in which these special [ModelElement]s can be found.
2925
static const String _packageName = 'Dart';
@@ -43,7 +39,7 @@ enum SpecialClass {
4339
/// Elements which must exist in the package graph when calling
4440
/// [SpecialClasses.new].
4541
static List<SpecialClass> get _requiredSpecialClasses =>
46-
[SpecialClass.enum_, SpecialClass.object];
42+
[SpecialClass.object];
4743

4844
/// Returns the path of the Dart Library where this [ModelElement] is
4945
/// declared, or `null` if its URI does not denote a library in the specified

0 commit comments

Comments
 (0)