Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up Class class, which is not a supertype of Enum class #3727

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1671,13 +1671,12 @@ class _Renderer_Class extends RendererBase<Class> {
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'InterfaceElement'),
c, remainingNames, 'ClassElement'),
isNullValue: (CT_ c) => false,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
renderSimple(c.element, ast, r.template, sink,
parent: r,
getters: _invisibleGetters['InterfaceElement']!);
parent: r, getters: _invisibleGetters['ClassElement']!);
},
),
'fileName': Property(
Expand Down Expand Up @@ -15981,6 +15980,27 @@ const _invisibleGetters = {
'lineNumber',
'runtimeType'
},
'ClassElement': {
'augmentation',
'augmentationTarget',
'augmented',
'hasNonFinalField',
'hashCode',
'isAbstract',
'isBase',
'isConstructable',
'isDartCoreEnum',
'isDartCoreObject',
'isExhaustive',
'isFinal',
'isInline',
'isInterface',
'isMixinApplication',
'isMixinClass',
'isSealed',
'isValidMixin',
'runtimeType'
},
'CommentReferable': {
'definingCommentReferable',
'href',
Expand Down
34 changes: 8 additions & 26 deletions lib/src/model/class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:dartdoc/src/model/model.dart';

/// A [Container] defined with a `class` or `enum` declaration.
/// A [Container] defined with a `class` declaration.
///
/// Members follow similar naming rules to [Container], with the following
/// additions:
Expand All @@ -14,7 +14,7 @@ import 'package:dartdoc/src/model/model.dart';
/// **inherited**: Filtered getters giving only inherited children.
class Class extends InheritingContainer with Constructable, MixedInTypes {
@override
final InterfaceElement element;
final ClassElement element;

@override
late final List<ModelElement> allModelElements = [
Expand Down Expand Up @@ -50,16 +50,10 @@ class Class extends InheritingContainer with Constructable, MixedInTypes {
String get fileName => '$name-class.html';

@override
bool get isAbstract => switch (element) {
ClassElement class_ when class_.isAbstract => true,
_ => false,
};
bool get isAbstract => element.isAbstract;

@override
bool get isBase => switch (element) {
ClassElement class_ when class_.isBase && !class_.isSealed => true,
_ => false,
};
bool get isBase => element.isBase && !element.isSealed;

bool get isErrorOrException {
bool isError(InterfaceElement element) =>
Expand All @@ -72,28 +66,16 @@ class Class extends InheritingContainer with Constructable, MixedInTypes {
}

@override
bool get isFinal => switch (element) {
ClassElement class_ when class_.isFinal && !class_.isSealed => true,
_ => false,
};
bool get isFinal => element.isFinal && !element.isSealed;

@override
bool get isInterface => switch (element) {
ClassElement class_ when class_.isInterface && !class_.isSealed => true,
_ => false,
};
bool get isInterface => element.isInterface && !element.isSealed;

@override
bool get isMixinClass => switch (element) {
ClassElement class_ when class_.isMixinClass => true,
_ => false,
};
bool get isMixinClass => element.isMixinClass;

@override
bool get isSealed => switch (element) {
ClassElement class_ when class_.isSealed => true,
_ => false,
};
bool get isSealed => element.isSealed;

@override
Kind get kind => Kind.class_;
Expand Down