From edf0ecfd187eb660cb1bbb4b5236bec166895764 Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Fri, 10 Nov 2023 20:32:15 +0000 Subject: [PATCH 1/5] @hideConstantImplementations by default. --- README.md | 35 ---------- .../templates.runtime_renderers.dart | 29 +-------- lib/src/model/container.dart | 2 +- lib/src/model/documentation_comment.dart | 13 ++-- lib/src/model/field.dart | 4 -- lib/src/model/getter_setter_combo.dart | 11 +--- lib/src/model/top_level_variable.dart | 4 -- test/constant_values_test.dart | 37 +++++++++++ .../hide_constant_implementations_test.dart | 65 ------------------- 9 files changed, 48 insertions(+), 152 deletions(-) delete mode 100644 test/directives/hide_constant_implementations_test.dart diff --git a/README.md b/README.md index c305102bc7..db62b5ee0a 100644 --- a/README.md +++ b/README.md @@ -408,41 +408,6 @@ markdown link isn't linked). It's best to only inject HTML that is self-contained and doesn't depend upon other elements on the page, since those may change in future versions of Dartdoc. -### Skipping constant rendering with one-line docs - -For some classes or libraries full of well-documented constants, showing the -implementation on the enclosing `class` or `library` page can be distracting -or even misleading. To prevent the rendering of constant implementations, -place the `{@hideConstantImplementations}` in the documentation comment for -the enclosing context where the constant is defined. For members of a class, -place the directive in the class documentation where the constants are defined. -For top level constants, place the directive in the library where the constants -are defined. - -For example: - -```dart -/// This is truly an amazing library. -/// {@hideConstantImplementations} -library my_library; - -/// This top level constant will not show its implementation. -const a = 7; - -/// {@hideConstantImplementations} -class A { - /// This constant will not show its implementation. - static const aConst = 12; -} - -class B { - /// Despite the library directive, because this is a class - /// member and there is no hideConstantImplementations - /// directive on the class, we will show this implementation. - static const bConst = 27; -} -``` - ### Auto including dependencies If `--auto-include-dependencies` flag is provided, dartdoc tries to automatically add diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index 67797eb8b1..2bcaf9a729 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -2777,7 +2777,6 @@ class _Renderer_Container extends RendererBase { ..._Renderer_ModelElement.propertyMap(), ..._Renderer_Categorization.propertyMap(), ..._Renderer_TypeParameters.propertyMap(), - ..._Renderer_HideConstantImplementations.propertyMap(), 'aboveSidebarPath': Property( getValue: (CT_ c) => c.aboveSidebarPath, renderVariable: @@ -6121,13 +6120,6 @@ class _Renderer_Field extends RendererBase { parent: r); }, ), - 'hasHideConstantImplementation': Property( - getValue: (CT_ c) => c.hasHideConstantImplementation, - renderVariable: (CT_ c, Property self, - List remainingNames) => - self.renderSimpleVariable(c, remainingNames, 'bool'), - getBool: (CT_ c) => c.hasHideConstantImplementation == true, - ), 'href': Property( getValue: (CT_ c) => c.href, renderVariable: @@ -6820,13 +6812,6 @@ class _Renderer_GetterSetterCombo extends RendererBase { self.renderSimpleVariable(c, remainingNames, 'bool'), getBool: (CT_ c) => c.hasGetterOrSetter == true, ), - 'hasHideConstantImplementation': Property( - getValue: (CT_ c) => c.hasHideConstantImplementation, - renderVariable: (CT_ c, Property self, - List remainingNames) => - self.renderSimpleVariable(c, remainingNames, 'bool'), - getBool: (CT_ c) => c.hasHideConstantImplementation == true, - ), 'hasNoGetterSetter': Property( getValue: (CT_ c) => c.hasNoGetterSetter, renderVariable: (CT_ c, Property self, @@ -12633,7 +12618,7 @@ class _Renderer_Package extends RendererBase { } } -String renderIndex(PackageTemplateData context, Template template) { +String renderSearchPage(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); @@ -12871,13 +12856,13 @@ class _Renderer_PackageTemplateData extends RendererBase { } } -String renderSearchPage(PackageTemplateData context, Template template) { +String renderError(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); } -String renderError(PackageTemplateData context, Template template) { +String renderIndex(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); @@ -15135,13 +15120,6 @@ class _Renderer_TopLevelVariable extends RendererBase { parent: r); }, ), - 'hasHideConstantImplementation': Property( - getValue: (CT_ c) => c.hasHideConstantImplementation, - renderVariable: (CT_ c, Property self, - List remainingNames) => - self.renderSimpleVariable(c, remainingNames, 'bool'), - getBool: (CT_ c) => c.hasHideConstantImplementation == true, - ), 'href': Property( getValue: (CT_ c) => c.href, renderVariable: @@ -16751,7 +16729,6 @@ const _invisibleGetters = { 'hasExplicitSetter', 'hasGetter', 'hasGetterOrSetter', - 'hasHideConstantImplementation', 'hasNoGetterSetter', 'hasParameters', 'hasPublicGetter', diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index cbac2462dc..6466b8b0c0 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -28,7 +28,7 @@ import 'package:meta/meta.dart'; /// * **has** : boolean getters indicating whether the underlying collections /// are empty. These are available mostly for the templating system. abstract class Container extends ModelElement - with Categorization, TypeParameters, HideConstantImplementations { + with Categorization, TypeParameters { Container(super.library, super.packageGraph); // TODO(jcollins-g): Implement a ContainerScope that flattens supertypes? diff --git a/lib/src/model/documentation_comment.dart b/lib/src/model/documentation_comment.dart index 734afba493..81673801dd 100644 --- a/lib/src/model/documentation_comment.dart +++ b/lib/src/model/documentation_comment.dart @@ -13,16 +13,16 @@ import 'package:dartdoc/src/warnings.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as p show Context; -final _templatePattern = RegExp( - r'[ ]*\{@template\s+([^\s}].*?)\}([^]+?)\{@endtemplate\}[ ]*(\n?)'); -final _htmlPattern = RegExp( - r'[ ]*\{@inject-html\s*\}([^]+?)\{@end-inject-html\}[ ]*\n?'); +final _templatePattern = + RegExp(r'[ ]*\{@template\s+([^\s}].*?)\}([^]+?)\{@endtemplate\}[ ]*(\n?)'); +final _htmlPattern = + RegExp(r'[ ]*\{@inject-html\s*\}([^]+?)\{@end-inject-html\}[ ]*\n?'); /// Matches all tool directives (even some invalid ones). This is so /// we can give good error messages if the directive is malformed, instead of /// just silently emitting it as-is. -final _basicToolPattern = RegExp( - r'[ ]*{@tool\s+([^\s}][^}]*)}\n?([^]+?)\n?{@end-tool}[ ]*\n?'); +final _basicToolPattern = + RegExp(r'[ ]*{@tool\s+([^\s}][^}]*)}\n?([^]+?)\n?{@end-tool}[ ]*\n?'); final _examplePattern = RegExp(r'{@example\s+([^\s}][^}]*)}'); @@ -157,7 +157,6 @@ mixin DocumentationComment // Other directives, parsed by `model/directives/*.dart`: 'canonicalFor', 'category', - 'hideConstantImplementations', 'subCategory', // Common Dart annotations which may decorate named parameters: diff --git a/lib/src/model/field.dart b/lib/src/model/field.dart index 25f29475cd..b82dc5a106 100644 --- a/lib/src/model/field.dart +++ b/lib/src/model/field.dart @@ -181,8 +181,4 @@ class Field extends ModelElement @override Inheritable? get overriddenElement => null; - - @override - bool get hasHideConstantImplementation => - definingEnclosingContainer.hasHideConstantImplementations; } diff --git a/lib/src/model/getter_setter_combo.dart b/lib/src/model/getter_setter_combo.dart index 2de9d4a9ef..7cb342aec3 100644 --- a/lib/src/model/getter_setter_combo.dart +++ b/lib/src/model/getter_setter_combo.dart @@ -58,12 +58,7 @@ mixin GetterSetterCombo on ModelElement { bool get isInherited; /// Whether this has a constant value which should be displayed. - bool get hasConstantValueForDisplay { - final element = this.element; - if (element is! ConstVariableElement) return false; - if (hasHideConstantImplementation) return false; - return element.constantInitializer != null; - } + bool get hasConstantValueForDisplay => false; Expression? get constantInitializer => (element as ConstVariableElement).constantInitializer; @@ -263,10 +258,6 @@ mixin GetterSetterCombo on ModelElement { // TODO(srawlins): This should be private. bool get writeOnly => hasPublicSetter && !hasPublicGetter; - /// True if the @hideConstantImplementations directive is present - /// in the defining enclosing element. - bool get hasHideConstantImplementation; - @override late final Map referenceChildren = { if (hasParameters) ...parameters.explicitOnCollisionWith(this), diff --git a/lib/src/model/top_level_variable.dart b/lib/src/model/top_level_variable.dart index fe1fb646b1..45cd14b1af 100644 --- a/lib/src/model/top_level_variable.dart +++ b/lib/src/model/top_level_variable.dart @@ -82,8 +82,4 @@ class TopLevelVariable extends ModelElement @override Iterable get referenceParents => [definingLibrary]; - - @override - bool get hasHideConstantImplementation => - definingLibrary.hasHideConstantImplementations; } diff --git a/test/constant_values_test.dart b/test/constant_values_test.dart index 94c10e44a7..c5cb1fbcd3 100644 --- a/test/constant_values_test.dart +++ b/test/constant_values_test.dart @@ -14,6 +14,7 @@ void main() { if (namedArgumentsAnywhereAllowed) { defineReflectiveTests(ConstantValuesWithNamedArgumentsAnywhereTest); } + defineReflectiveTests(HiddenConstantsTest); }); } @@ -179,3 +180,39 @@ const r = C(c: 1, d: 2, 3, 4); equals('C(c: 1, d: 2, 3, 4)')); } } + +@reflectiveTest +class HiddenConstantsTest extends DartdocTestBase { + @override + String get libraryName => 'hidden_constants'; + + void test_field() async { + var library = await bootPackageWithLibrary(''' +/// Some documentation. +class A { + static const int aConst = 12; +} +'''); + var aClass = library.classes.named('A'); + var aConst = aClass.constantFields.named('aConst'); + expect(aConst.hasConstantValueForDisplay, isFalse); + expect(aClass.documentation, equals('Some documentation.')); + } + + void test_topLevel() async { + var library = await bootPackageWithLibrary(''' +class A { + static const int aConst = 12; +} + +static const aTopLevelConst = 37; +''', libraryPreamble: ''' +/// Some documentation. +'''); + var aConst = library.classes.named('A').constantFields.named('aConst'); + expect(aConst.hasConstantValueForDisplay, isFalse); + var aTopLevelConst = library.constants.named('aTopLevelConst'); + expect(aTopLevelConst.hasConstantValueForDisplay, isFalse); + expect(library.documentation, equals('Some documentation.')); + } +} diff --git a/test/directives/hide_constant_implementations_test.dart b/test/directives/hide_constant_implementations_test.dart deleted file mode 100644 index 6521f07531..0000000000 --- a/test/directives/hide_constant_implementations_test.dart +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:test/test.dart'; -import 'package:test_reflective_loader/test_reflective_loader.dart'; - -import '../dartdoc_test_base.dart'; -import '../src/utils.dart'; - -void main() { - defineReflectiveSuite(() { - defineReflectiveTests(HideConstantImplementationsTest); - }); -} - -@reflectiveTest -class HideConstantImplementationsTest extends DartdocTestBase { - @override - String get libraryName => 'hide_constant_implementations'; - @override - String get sdkConstraint => '>=2.18.0 <4.0.0'; - - void test_noDirectiveAllows() async { - var library = await bootPackageWithLibrary(''' -class A { - static const int aConst = 12; -} -'''); - var aConst = library.classes.named('A').constantFields.named('aConst'); - expect(aConst.hasConstantValueForDisplay, isTrue); - } - - void test_directiveDenies() async { - var library = await bootPackageWithLibrary(''' -/// Some documentation. -/// {@hideConstantImplementations} -class A { - static const int aConst = 12; -} -'''); - var aClass = library.classes.named('A'); - var aConst = aClass.constantFields.named('aConst'); - expect(aConst.hasConstantValueForDisplay, isFalse); - expect(aClass.documentation, equals('Some documentation.\n')); - } - - void test_libraryDirectiveImpactsTopLevelOnly() async { - var library = await bootPackageWithLibrary(''' -class A { - static const int aConst = 12; -} - -static const aTopLevelConst = 37; -''', libraryPreamble: ''' -/// Some documentation. -/// {@hideConstantImplementations} -'''); - var aConst = library.classes.named('A').constantFields.named('aConst'); - expect(aConst.hasConstantValueForDisplay, isTrue); - var aTopLevelConst = library.constants.named('aTopLevelConst'); - expect(aTopLevelConst.hasConstantValueForDisplay, isFalse); - expect(library.documentation, equals('Some documentation.\n')); - } -} From 568fe7ede80ee048a0993b0147f0b99082e3b637 Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Thu, 16 Nov 2023 20:38:15 +0000 Subject: [PATCH 2/5] Remove more parts of the directive, but allow parsing. --- .../templates.runtime_renderers.dart | 37 +---------------- .../hide_constant_implementations.dart | 41 ------------------- lib/src/model/documentation_comment.dart | 1 + lib/src/model/library.dart | 6 +-- lib/src/model/model.dart | 1 - 5 files changed, 4 insertions(+), 82 deletions(-) delete mode 100644 lib/src/model/directives/hide_constant_implementations.dart diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index 2bcaf9a729..bbf8a6c2f3 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -7114,38 +7114,6 @@ class _Renderer_HasNoPage extends RendererBase { } } -class _Renderer_HideConstantImplementations - extends RendererBase { - static final Map _propertyMapCache = {}; - static Map> - propertyMap() => - _propertyMapCache.putIfAbsent( - CT_, - () => { - 'hasHideConstantImplementations': Property( - getValue: (CT_ c) => c.hasHideConstantImplementations, - renderVariable: (CT_ c, Property self, - List remainingNames) => - self.renderSimpleVariable(c, remainingNames, 'bool'), - getBool: (CT_ c) => - c.hasHideConstantImplementations == true, - ), - }) as Map>; - - _Renderer_HideConstantImplementations(HideConstantImplementations 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; - } - } -} - class _Renderer_Indexable extends RendererBase { static final Map _propertyMapCache = {}; static Map> propertyMap() => @@ -8166,7 +8134,6 @@ class _Renderer_Library extends RendererBase { ..._Renderer_Categorization.propertyMap(), ..._Renderer_TopLevelContainer.propertyMap(), ..._Renderer_CanonicalFor.propertyMap(), - ..._Renderer_HideConstantImplementations.propertyMap(), 'aboveSidebarPath': Property( getValue: (CT_ c) => c.aboveSidebarPath, renderVariable: @@ -12856,13 +12823,13 @@ class _Renderer_PackageTemplateData extends RendererBase { } } -String renderError(PackageTemplateData context, Template template) { +String renderIndex(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); } -String renderIndex(PackageTemplateData context, Template template) { +String renderError(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); diff --git a/lib/src/model/directives/hide_constant_implementations.dart b/lib/src/model/directives/hide_constant_implementations.dart deleted file mode 100644 index 9815cf88e0..0000000000 --- a/lib/src/model/directives/hide_constant_implementations.dart +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:dartdoc/src/model/documentation_comment.dart'; -import 'package:dartdoc/src/model/model_element.dart'; - -final _hideConstantImplementationsRegExp = - RegExp(r'{@hideConstantImplementations}'); - -/// Implement parsing the hideConstantImplementations dartdoc directive -/// for this [ModelElement]. Used by [Container]. -mixin HideConstantImplementations on DocumentationComment { - bool? _hasHideConstantImplementations; - - /// [true] if the `{@hideConstantImplementations}` dartdoc directive is - /// present in the documentation for this class. - bool get hasHideConstantImplementations { - if (_hasHideConstantImplementations == null) { - buildDocumentationAddition(documentationComment); - } - return _hasHideConstantImplementations!; - } - - /// Hides `{@hideConstantImplementations}` from doc while leaving a note to - /// ourselves to change rendering for these constants. - /// Example: - /// - /// {@hideConstantImplementations} - @override - String buildDocumentationAddition(String rawDocs) { - rawDocs = super.buildDocumentationAddition(rawDocs); - _hasHideConstantImplementations = false; - rawDocs = rawDocs.replaceAllMapped(_hideConstantImplementationsRegExp, - (Match match) { - _hasHideConstantImplementations = true; - return ''; - }); - return rawDocs; - } -} diff --git a/lib/src/model/documentation_comment.dart b/lib/src/model/documentation_comment.dart index 81673801dd..fcbdb9163e 100644 --- a/lib/src/model/documentation_comment.dart +++ b/lib/src/model/documentation_comment.dart @@ -157,6 +157,7 @@ mixin DocumentationComment // Other directives, parsed by `model/directives/*.dart`: 'canonicalFor', 'category', + 'hideConstantImplementations', 'subCategory', // Common Dart annotations which may decorate named parameters: diff --git a/lib/src/model/library.dart b/lib/src/model/library.dart index 333be988e0..7db69bd62b 100644 --- a/lib/src/model/library.dart +++ b/lib/src/model/library.dart @@ -22,11 +22,7 @@ class _LibrarySentinel implements Library { } class Library extends ModelElement - with - Categorization, - TopLevelContainer, - CanonicalFor, - HideConstantImplementations { + with Categorization, TopLevelContainer, CanonicalFor { @override final LibraryElement element; diff --git a/lib/src/model/model.dart b/lib/src/model/model.dart index 2c3954286b..f3e9e80522 100644 --- a/lib/src/model/model.dart +++ b/lib/src/model/model.dart @@ -11,7 +11,6 @@ export 'container.dart'; export 'container_member.dart'; export 'directives/canonical_for.dart'; export 'directives/categorization.dart'; -export 'directives/hide_constant_implementations.dart'; export 'documentable.dart'; export 'documentation.dart'; export 'documentation_comment.dart'; From 1c82c3df6a702d375a08853912c47aeaeae6cc0e Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Thu, 16 Nov 2023 22:12:34 +0000 Subject: [PATCH 3/5] Revert some deletions. --- .../hide_constant_implementations.dart | 41 +++++++++++++++++++ lib/src/model/library.dart | 6 ++- lib/src/model/model.dart | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 lib/src/model/directives/hide_constant_implementations.dart diff --git a/lib/src/model/directives/hide_constant_implementations.dart b/lib/src/model/directives/hide_constant_implementations.dart new file mode 100644 index 0000000000..9815cf88e0 --- /dev/null +++ b/lib/src/model/directives/hide_constant_implementations.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:dartdoc/src/model/documentation_comment.dart'; +import 'package:dartdoc/src/model/model_element.dart'; + +final _hideConstantImplementationsRegExp = + RegExp(r'{@hideConstantImplementations}'); + +/// Implement parsing the hideConstantImplementations dartdoc directive +/// for this [ModelElement]. Used by [Container]. +mixin HideConstantImplementations on DocumentationComment { + bool? _hasHideConstantImplementations; + + /// [true] if the `{@hideConstantImplementations}` dartdoc directive is + /// present in the documentation for this class. + bool get hasHideConstantImplementations { + if (_hasHideConstantImplementations == null) { + buildDocumentationAddition(documentationComment); + } + return _hasHideConstantImplementations!; + } + + /// Hides `{@hideConstantImplementations}` from doc while leaving a note to + /// ourselves to change rendering for these constants. + /// Example: + /// + /// {@hideConstantImplementations} + @override + String buildDocumentationAddition(String rawDocs) { + rawDocs = super.buildDocumentationAddition(rawDocs); + _hasHideConstantImplementations = false; + rawDocs = rawDocs.replaceAllMapped(_hideConstantImplementationsRegExp, + (Match match) { + _hasHideConstantImplementations = true; + return ''; + }); + return rawDocs; + } +} diff --git a/lib/src/model/library.dart b/lib/src/model/library.dart index 7db69bd62b..333be988e0 100644 --- a/lib/src/model/library.dart +++ b/lib/src/model/library.dart @@ -22,7 +22,11 @@ class _LibrarySentinel implements Library { } class Library extends ModelElement - with Categorization, TopLevelContainer, CanonicalFor { + with + Categorization, + TopLevelContainer, + CanonicalFor, + HideConstantImplementations { @override final LibraryElement element; diff --git a/lib/src/model/model.dart b/lib/src/model/model.dart index f3e9e80522..2c3954286b 100644 --- a/lib/src/model/model.dart +++ b/lib/src/model/model.dart @@ -11,6 +11,7 @@ export 'container.dart'; export 'container_member.dart'; export 'directives/canonical_for.dart'; export 'directives/categorization.dart'; +export 'directives/hide_constant_implementations.dart'; export 'documentable.dart'; export 'documentation.dart'; export 'documentation_comment.dart'; From 449ed723c17b78532f50d8ff7c087fe8f47f79ab Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Thu, 16 Nov 2023 22:27:48 +0000 Subject: [PATCH 4/5] Fix generated. --- .../templates.runtime_renderers.dart | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index bbf8a6c2f3..2bcaf9a729 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -7114,6 +7114,38 @@ class _Renderer_HasNoPage extends RendererBase { } } +class _Renderer_HideConstantImplementations + extends RendererBase { + static final Map _propertyMapCache = {}; + static Map> + propertyMap() => + _propertyMapCache.putIfAbsent( + CT_, + () => { + 'hasHideConstantImplementations': Property( + getValue: (CT_ c) => c.hasHideConstantImplementations, + renderVariable: (CT_ c, Property self, + List remainingNames) => + self.renderSimpleVariable(c, remainingNames, 'bool'), + getBool: (CT_ c) => + c.hasHideConstantImplementations == true, + ), + }) as Map>; + + _Renderer_HideConstantImplementations(HideConstantImplementations 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; + } + } +} + class _Renderer_Indexable extends RendererBase { static final Map _propertyMapCache = {}; static Map> propertyMap() => @@ -8134,6 +8166,7 @@ class _Renderer_Library extends RendererBase { ..._Renderer_Categorization.propertyMap(), ..._Renderer_TopLevelContainer.propertyMap(), ..._Renderer_CanonicalFor.propertyMap(), + ..._Renderer_HideConstantImplementations.propertyMap(), 'aboveSidebarPath': Property( getValue: (CT_ c) => c.aboveSidebarPath, renderVariable: @@ -12823,13 +12856,13 @@ class _Renderer_PackageTemplateData extends RendererBase { } } -String renderIndex(PackageTemplateData context, Template template) { +String renderError(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); } -String renderError(PackageTemplateData context, Template template) { +String renderIndex(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); From 6af03c71e74ad581901c290330851799d9ca53c8 Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Thu, 16 Nov 2023 23:01:27 +0000 Subject: [PATCH 5/5] Flutter checks for replaced directives. --- lib/src/generator/templates.runtime_renderers.dart | 7 ++++--- lib/src/model/container.dart | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index 2bcaf9a729..1d10b319a5 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -2777,6 +2777,7 @@ class _Renderer_Container extends RendererBase { ..._Renderer_ModelElement.propertyMap(), ..._Renderer_Categorization.propertyMap(), ..._Renderer_TypeParameters.propertyMap(), + ..._Renderer_HideConstantImplementations.propertyMap(), 'aboveSidebarPath': Property( getValue: (CT_ c) => c.aboveSidebarPath, renderVariable: @@ -12618,7 +12619,7 @@ class _Renderer_Package extends RendererBase { } } -String renderSearchPage(PackageTemplateData context, Template template) { +String renderIndex(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); @@ -12856,13 +12857,13 @@ class _Renderer_PackageTemplateData extends RendererBase { } } -String renderError(PackageTemplateData context, Template template) { +String renderSearchPage(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); } -String renderIndex(PackageTemplateData context, Template template) { +String renderError(PackageTemplateData context, Template template) { var buffer = StringBuffer(); _render_PackageTemplateData(context, template.ast, template, buffer); return buffer.toString(); diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 6466b8b0c0..cbac2462dc 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -28,7 +28,7 @@ import 'package:meta/meta.dart'; /// * **has** : boolean getters indicating whether the underlying collections /// are empty. These are available mostly for the templating system. abstract class Container extends ModelElement - with Categorization, TypeParameters { + with Categorization, TypeParameters, HideConstantImplementations { Container(super.library, super.packageGraph); // TODO(jcollins-g): Implement a ContainerScope that flattens supertypes?