From 8881264930929d2e094c9280561c6199c748254a Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 5 Oct 2020 11:18:33 -0700 Subject: [PATCH] Adjust interfaces for mustache. * Even though ModelElement has `hasCategoryNames`, the _categorization partial references `displayedCategories`, so it must exist. * _sidebar_for_container references `hasPublicConstructors`, `publicConstructorsSorted`, `publicInheritedInstanceFields`, `publicInheritedInstanceMethods`, `publicInheritedInstanceOperators`. * Category.linkedName is referenced by templates, so it should no longer be deprecated. --- lib/src/model/categorization.dart | 1 + lib/src/model/category.dart | 2 -- lib/src/model/class.dart | 7 +++++-- lib/src/model/container.dart | 19 +++++++++++++++++++ lib/src/model/model_element.dart | 7 +++++-- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/src/model/categorization.dart b/lib/src/model/categorization.dart index afed68b8ce..0dcce68f91 100644 --- a/lib/src/model/categorization.dart +++ b/lib/src/model/categorization.dart @@ -111,6 +111,7 @@ abstract class Categorization implements ModelElement { return _categories; } + @override Iterable get displayedCategories { if (config.showUndocumentedCategories) return categories; return categories.where((c) => c.isDocumented); diff --git a/lib/src/model/category.dart b/lib/src/model/category.dart index 8d4eb3e5d9..c5cedd56ef 100644 --- a/lib/src/model/category.dart +++ b/lib/src/model/category.dart @@ -149,8 +149,6 @@ class Category extends Nameable String get categoryLabel => _categoryRenderer.renderCategoryLabel(this); - @Deprecated( - 'Public field is unused; will be removed as early as Dartdoc 1.0.0') String get linkedName => _categoryRenderer.renderLinkedName(this); int _categoryIndex; diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index 4496a29dfc..f320658dfb 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -77,7 +77,7 @@ class Class extends Container Iterable get instanceMethods => quiver.concat([super.instanceMethods, inheritedMethods]); - // Whether all instance methods are inherited, used in mustache templates. + @override bool get publicInheritedInstanceMethods => instanceMethods.every((f) => f.isInherited); @@ -131,11 +131,12 @@ class Class extends Container return kind; } - // Whether any constructors are public, used in mustache templates. + @override bool get hasPublicConstructors => publicConstructorsSorted.isNotEmpty; List _publicConstructorsSorted; + @override List get publicConstructorsSorted => _publicConstructorsSorted ??= publicConstructors.toList()..sort(byName); @@ -247,6 +248,7 @@ class Class extends Container return _inheritedOperators; } + @override Iterable get publicInheritedInstanceOperators => model_utils.filterNonPublic(inheritedOperators); @@ -524,6 +526,7 @@ class Class extends Container Iterable get instanceFields => _instanceFields ??= allFields.where((f) => !f.isStatic); + @override bool get publicInheritedInstanceFields => publicInstanceFields.every((f) => f.isInherited); diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index c5982d36a9..8047b0542d 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -54,6 +54,25 @@ abstract class Container extends ModelElement with TypeParameters { .where((m) => !m.isStatic && !m.isOperator) .toList(growable: false); + /// Whether any constructors are public. + /// + /// This is only used in mustache templates. + bool get hasPublicConstructors => false; + + Iterable get publicConstructorsSorted => []; + + /// Whether all instance fields are inherited. + /// + /// This is only used in mustache templates. + bool get publicInheritedInstanceFields => false; + + /// Whether all instance methods are inherited. + /// + /// This is only used in mustache templates. + bool get publicInheritedInstanceMethods => false; + + Iterable get publicInheritedInstanceOperators => []; + @nonVirtual bool get hasPublicInstanceMethods => model_utils.filterNonPublic(instanceMethods).isNotEmpty; diff --git a/lib/src/model/model_element.dart b/lib/src/model/model_element.dart index 0f25cfa53a..9dd33e9504 100644 --- a/lib/src/model/model_element.dart +++ b/lib/src/model/model_element.dart @@ -382,10 +382,13 @@ abstract class ModelElement extends Canonicalization throw 'Unknown type ${e.runtimeType}'; } - /// Stub for mustache4dart, or it will search enclosing elements to find - /// names for members. + // Stub for mustache, which would otherwise search enclosing elements to find + // names for members. bool get hasCategoryNames => false; + // Stub for mustache. + Iterable get displayedCategories => []; + Set get exportedInLibraries { return library.packageGraph.libraryElementReexportedBy[element.library]; }