Skip to content

Commit

Permalink
Do not use SpecialClass to evaluate Enum or Interceptor (#3928)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins authored Nov 14, 2024
1 parent dcc239a commit 6bbd3d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
14 changes: 13 additions & 1 deletion lib/src/model/inheritable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 0 additions & 17 deletions lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Class> _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<Class> _invisibleAnnotations = {
Expand Down
8 changes: 2 additions & 6 deletions lib/src/special_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -43,7 +39,7 @@ enum SpecialClass {
/// Elements which must exist in the package graph when calling
/// [SpecialClasses.new].
static List<SpecialClass> 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
Expand Down

0 comments on commit 6bbd3d7

Please sign in to comment.