diff --git a/lib/src/dartdoc_options.dart b/lib/src/dartdoc_options.dart index d2ef289035..dfbd10daf8 100644 --- a/lib/src/dartdoc_options.dart +++ b/lib/src/dartdoc_options.dart @@ -651,7 +651,7 @@ class DartdocOptionSyntheticOnly extends DartdocOption : super(name, null, help, optionIs, mustExist, null, resourceProvider); } -abstract class DartdocSyntheticOption implements DartdocOption { +mixin DartdocSyntheticOption implements DartdocOption { T Function(DartdocSyntheticOption, Folder) get _compute; @override @@ -841,7 +841,7 @@ class DartdocOptionFileOnly extends DartdocOption } /// Implements checking for options contained in dartdoc.yaml. -abstract class _DartdocFileOption implements DartdocOption { +mixin _DartdocFileOption implements DartdocOption { /// If true, the parent directory's value overrides the child's. /// /// Otherwise, the child's value overrides values in parents. @@ -1018,7 +1018,7 @@ abstract class _DartdocFileOption implements DartdocOption { } /// Mixin class implementing command-line arguments for [DartdocOption]. -abstract class _DartdocArgOption implements DartdocOption { +mixin _DartdocArgOption implements DartdocOption { /// For [ArgParser], set to true if the argument can be negated with `--no` on /// the command line. bool get negatable; diff --git a/lib/src/element_type.dart b/lib/src/element_type.dart index e138d0f7ed..1fe61bae4f 100644 --- a/lib/src/element_type.dart +++ b/lib/src/element_type.dart @@ -25,8 +25,9 @@ mixin ElementTypeBuilderImpl implements ElementTypeBuilder { /// Base class representing a type in Dartdoc. It wraps a [DartType], and /// may link to a [ModelElement]. -abstract class ElementType extends Privacy - with CommentReferable, Nameable, ModelBuilder { +abstract class ElementType + with CommentReferable, Nameable, ModelBuilder + implements Privacy { final DartType type; @override final PackageGraph packageGraph; diff --git a/lib/src/experiment_options.dart b/lib/src/experiment_options.dart index 623a9604ea..0e573d5c50 100644 --- a/lib/src/experiment_options.dart +++ b/lib/src/experiment_options.dart @@ -13,8 +13,7 @@ import 'package:analyzer/file_system/file_system.dart'; import 'package:analyzer/src/dart/analysis/experiments.dart'; import 'package:dartdoc/src/dartdoc_options.dart'; -abstract class DartdocExperimentOptionContext - implements DartdocOptionContextBase { +mixin DartdocExperimentOptionContext implements DartdocOptionContextBase { List get enableExperiment => optionSet['enable-experiment'].valueAt(context); } diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index 8f3fb26dca..5859f2a0d5 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -757,7 +757,6 @@ class _Renderer_Categorization extends RendererBase { _propertyMapCache.putIfAbsent( CT_, () => { - ..._Renderer_Object.propertyMap(), 'categories': Property( getValue: (CT_ c) => c.categories, renderVariable: (CT_ c, Property self, @@ -4110,7 +4109,7 @@ class _Renderer_ElementType extends RendererBase { _propertyMapCache.putIfAbsent( CT_, () => { - ..._Renderer_Privacy.propertyMap(), + ..._Renderer_Object.propertyMap(), ..._Renderer_CommentReferable.propertyMap(), ..._Renderer_Nameable.propertyMap(), ..._Renderer_ModelBuilder.propertyMap(), @@ -6535,7 +6534,6 @@ class _Renderer_Indexable extends RendererBase { _propertyMapCache.putIfAbsent( CT_, () => { - ..._Renderer_Object.propertyMap(), 'href': Property( getValue: (CT_ c) => c.href, renderVariable: @@ -8546,7 +8544,6 @@ class _Renderer_Locatable extends RendererBase { _propertyMapCache.putIfAbsent( CT_, () => { - ..._Renderer_Object.propertyMap(), 'documentationFrom': Property( getValue: (CT_ c) => c.documentationFrom, renderVariable: (CT_ c, Property self, @@ -9754,11 +9751,10 @@ class _Renderer_ModelElement extends RendererBase { () => { ..._Renderer_Canonicalization.propertyMap(), ..._Renderer_CommentReferable.propertyMap(), - ..._Renderer_Privacy.propertyMap(), ..._Renderer_Warnable.propertyMap(), ..._Renderer_Locatable.propertyMap(), ..._Renderer_Nameable.propertyMap(), - ..._Renderer_SourceCodeMixin.propertyMap(), + ..._Renderer_SourceCode.propertyMap(), ..._Renderer_Indexable.propertyMap(), ..._Renderer_FeatureSet.propertyMap(), ..._Renderer_DocumentationComment.propertyMap(), @@ -12657,36 +12653,6 @@ class _Renderer_ParameterizedElementType } } -class _Renderer_Privacy extends RendererBase { - static final Map _propertyMapCache = {}; - static Map> propertyMap() => - _propertyMapCache.putIfAbsent( - CT_, - () => { - ..._Renderer_Object.propertyMap(), - 'isPublic': Property( - getValue: (CT_ c) => c.isPublic, - renderVariable: (CT_ c, Property self, - List remainingNames) => - self.renderSimpleVariable(c, remainingNames, 'bool'), - getBool: (CT_ c) => c.isPublic == true, - ), - }) as Map>; - - _Renderer_Privacy(Privacy context, RendererBase? parent, - Template template, StringSink sink) - : super(context, parent, template, sink); - - @override - Property? getProperty(String key) { - if (propertyMap().containsKey(key)) { - return propertyMap()[key]; - } else { - return null; - } - } -} - String renderProperty(PropertyTemplateData context, Template template) { var buffer = StringBuffer(); _render_PropertyTemplateData(context, template.ast, template, buffer); @@ -12991,14 +12957,12 @@ class _Renderer_Rendered extends RendererBase { } } -class _Renderer_SourceCodeMixin extends RendererBase { +class _Renderer_SourceCode extends RendererBase { static final Map _propertyMapCache = {}; - static Map> propertyMap< - CT_ extends SourceCodeMixin>() => + static Map> propertyMap() => _propertyMapCache.putIfAbsent( CT_, () => { - ..._Renderer_Object.propertyMap(), 'characterLocation': Property( getValue: (CT_ c) => c.characterLocation, renderVariable: (CT_ c, Property self, @@ -13090,14 +13054,14 @@ class _Renderer_SourceCodeMixin extends RendererBase { ), }) as Map>; - _Renderer_SourceCodeMixin(SourceCodeMixin context, - RendererBase? parent, Template template, StringSink sink) + _Renderer_SourceCode(SourceCode context, RendererBase? parent, + Template template, StringSink sink) : super(context, parent, template, sink); @override - Property? getProperty(String key) { - if (propertyMap().containsKey(key)) { - return propertyMap()[key]; + Property? getProperty(String key) { + if (propertyMap().containsKey(key)) { + return propertyMap()[key]; } else { return null; } @@ -13789,7 +13753,6 @@ class _Renderer_TopLevelContainer extends RendererBase { _propertyMapCache.putIfAbsent( CT_, () => { - ..._Renderer_Object.propertyMap(), 'classes': Property( getValue: (CT_ c) => c.classes, renderVariable: (CT_ c, Property self, @@ -16255,10 +16218,8 @@ const _invisibleGetters = { 'documentationFrom', 'documentationIsLocal', 'fullyQualifiedName', - 'hashCode', 'href', - 'location', - 'runtimeType' + 'location' }, 'Map': { 'entries', diff --git a/lib/src/logging.dart b/lib/src/logging.dart index d80d8b285c..f4b8abb13d 100644 --- a/lib/src/logging.dart +++ b/lib/src/logging.dart @@ -125,7 +125,7 @@ void startLogging(LoggingContext config) { } } -abstract class LoggingContext implements DartdocOptionContextBase { +mixin LoggingContext on DartdocOptionContextBase { bool get json => optionSet['json'].valueAt(context); bool get showProgress => optionSet['showProgress'].valueAt(context); diff --git a/lib/src/model/canonicalization.dart b/lib/src/model/canonicalization.dart index b9b0798701..502d567ca0 100644 --- a/lib/src/model/canonicalization.dart +++ b/lib/src/model/canonicalization.dart @@ -5,7 +5,7 @@ import 'package:dartdoc/src/model/model.dart'; /// Classes extending this class have canonicalization support in Dartdoc. -abstract class Canonicalization implements Locatable, Documentable { +abstract /*mixin*/ class Canonicalization implements Locatable, Documentable { bool get isCanonical; Library? get canonicalLibrary; diff --git a/lib/src/model/categorization.dart b/lib/src/model/categorization.dart index 54bf413abb..e69212f7b3 100644 --- a/lib/src/model/categorization.dart +++ b/lib/src/model/categorization.dart @@ -10,7 +10,7 @@ final RegExp _categoryRegExp = RegExp( multiLine: true); /// Mixin implementing dartdoc categorization for ModelElements. -abstract class Categorization implements ModelElement { +mixin Categorization implements ModelElement { @override String buildDocumentationAddition(String rawDocs) => _stripAndSetDartdocCategories(rawDocs); diff --git a/lib/src/model/documentation_comment.dart b/lib/src/model/documentation_comment.dart index 27a5449e97..5fc75f065f 100644 --- a/lib/src/model/documentation_comment.dart +++ b/lib/src/model/documentation_comment.dart @@ -36,8 +36,7 @@ final _htmlInjectRegExp = RegExp(r'([a-f0-9]+)'); /// /// [_processCommentWithoutTools] and [processComment] are the primary /// entrypoints. -mixin DocumentationComment - on Documentable, Warnable, Locatable, SourceCodeMixin { +mixin DocumentationComment on Documentable, Warnable, Locatable, SourceCode { @override Element get element; diff --git a/lib/src/model/indexable.dart b/lib/src/model/indexable.dart index c96e77cb8c..6166816ecf 100644 --- a/lib/src/model/indexable.dart +++ b/lib/src/model/indexable.dart @@ -5,7 +5,7 @@ import 'package:dartdoc/src/model/model.dart'; /// Something able to be indexed. -abstract class Indexable implements Nameable { +mixin Indexable implements Nameable { String? get href; String get kind; diff --git a/lib/src/model/library_container.dart b/lib/src/model/library_container.dart index 5bef164759..5083745c03 100644 --- a/lib/src/model/library_container.dart +++ b/lib/src/model/library_container.dart @@ -10,7 +10,7 @@ import 'package:dartdoc/src/model_utils.dart' as model_utils; /// /// Do not cache return values of any methods or members excepting [libraries] /// and [name] before finishing initialization of a [LibraryContainer]. -abstract class LibraryContainer +abstract /*mixin*/ class LibraryContainer implements Nameable, Comparable { final List libraries = []; diff --git a/lib/src/model/locatable.dart b/lib/src/model/locatable.dart index 3fa1116aa5..9df52ef580 100644 --- a/lib/src/model/locatable.dart +++ b/lib/src/model/locatable.dart @@ -5,7 +5,7 @@ import 'package:analyzer/dart/element/element.dart' show Element; /// Something that can be located for warning purposes. -abstract class Locatable { +mixin Locatable { List get documentationFrom; /// True if documentationFrom contains only one item, [this]. diff --git a/lib/src/model/model_element.dart b/lib/src/model/model_element.dart index 6226b1bada..d28d00b792 100644 --- a/lib/src/model/model_element.dart +++ b/lib/src/model/model_element.dart @@ -114,16 +114,15 @@ mixin ModelElementBuilderImpl implements ModelElementBuilder { abstract class ModelElement extends Canonicalization with CommentReferable, - Privacy, Warnable, Locatable, Nameable, - SourceCodeMixin, + SourceCode, Indexable, FeatureSet, DocumentationComment, ModelBuilder - implements Comparable, Documentable { + implements Comparable, Documentable, Privacy { // TODO(jcollins-g): This really wants a "member that has a type" class. final Member? _originalMember; final Library _library; diff --git a/lib/src/model/nameable.dart b/lib/src/model/nameable.dart index 323e76e1af..e2ec384954 100644 --- a/lib/src/model/nameable.dart +++ b/lib/src/model/nameable.dart @@ -7,7 +7,7 @@ import 'package:collection/collection.dart'; import 'locatable.dart'; /// Something that has a name. -abstract class Nameable { +abstract /*mixin*/ class Nameable { String get name; String get fullyQualifiedName => name; diff --git a/lib/src/model/privacy.dart b/lib/src/model/privacy.dart index 9961eb0dda..03565faca1 100644 --- a/lib/src/model/privacy.dart +++ b/lib/src/model/privacy.dart @@ -3,6 +3,6 @@ // BSD-style license that can be found in the LICENSE file. /// Classes implementing this have a public/private distinction. -abstract class Privacy { +abstract /*interface*/ class Privacy { bool get isPublic; } diff --git a/lib/src/model/source_code_mixin.dart b/lib/src/model/source_code_mixin.dart index cdd050f1ea..eafd92bfeb 100644 --- a/lib/src/model/source_code_mixin.dart +++ b/lib/src/model/source_code_mixin.dart @@ -6,7 +6,7 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/source/line_info.dart'; import 'package:dartdoc/src/model/model.dart'; -abstract class SourceCodeMixin implements Documentable { +mixin SourceCode implements Documentable { ModelNode? get modelNode; CharacterLocation? get characterLocation; diff --git a/lib/src/model/top_level_container.dart b/lib/src/model/top_level_container.dart index cfef3a9f7f..79173dbf10 100644 --- a/lib/src/model/top_level_container.dart +++ b/lib/src/model/top_level_container.dart @@ -11,7 +11,7 @@ import 'package:dartdoc/src/model_utils.dart' as model_utils; /// /// Do not call any methods or members excepting [name] and the private Lists /// below before finishing initialization of a [TopLevelContainer]. -abstract class TopLevelContainer implements Nameable { +mixin TopLevelContainer implements Nameable { Iterable get classes; Iterable get extensions; diff --git a/lib/src/source_linker.dart b/lib/src/source_linker.dart index b301740937..709651fba5 100644 --- a/lib/src/source_linker.dart +++ b/lib/src/source_linker.dart @@ -12,7 +12,7 @@ import 'package:path/path.dart' as p; final _uriTemplateRegExp = RegExp(r'(%[frl]%)'); -abstract class SourceLinkerOptionContext implements DartdocOptionContextBase { +mixin SourceLinkerOptionContext implements DartdocOptionContextBase { List get linkToSourceExcludes => optionSet['linkToSource']['excludes'].valueAt(context); diff --git a/lib/src/warnings.dart b/lib/src/warnings.dart index fa47f2afbc..b8c41e899a 100644 --- a/lib/src/warnings.dart +++ b/lib/src/warnings.dart @@ -14,7 +14,7 @@ import 'package:dartdoc/src/package_meta.dart'; const _namePlaceholder = '@@name@@'; -abstract class PackageWarningOptionContext implements DartdocOptionContextBase { +mixin PackageWarningOptionContext implements DartdocOptionContextBase { bool get allowNonLocalWarnings => optionSet['allowNonLocalWarnings'].valueAt(context); diff --git a/test/package_meta_test.dart b/test/package_meta_test.dart index 340743058c..a7f0cd1414 100644 --- a/test/package_meta_test.dart +++ b/test/package_meta_test.dart @@ -131,7 +131,7 @@ void main() { expect( resourceProvider .readAsMalformedAllowedStringSync(p.getReadmeContents()!), - startsWith('Welcome')); + contains('Welcome to the')); }); test('does not have a license', () {