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

Display extension type super interfaces #3554

Merged
merged 1 commit into from
Oct 26, 2023
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
71 changes: 51 additions & 20 deletions lib/src/generator/templates.aot_renderers_for_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -862,15 +862,19 @@ String renderExtensionType<T extends ExtensionType>(
buffer.write('''
</ul>
</dd>
''');
buffer.write(_renderExtensionType_partial_interfaces_5(context2));
buffer.writeln();
buffer.write('''
</dl>
''');
buffer.write(_renderExtensionType_partial_container_annotations_5(context2));
buffer.write(_renderExtensionType_partial_container_annotations_6(context2));
buffer.writeln();
buffer.write('''
</section>

''');
buffer.write(_renderExtensionType_partial_constructors_6(context2));
buffer.write(_renderExtensionType_partial_constructors_7(context2));
buffer.writeln();
if (context2.hasPublicInstanceFields == true) {
buffer.writeln();
Expand All @@ -882,31 +886,31 @@ String renderExtensionType<T extends ExtensionType>(
var context4 = context2.publicInstanceFieldsSorted;
for (var context5 in context4) {
buffer.write('\n ');
buffer.write(_renderExtensionType_partial_property_7(context5));
buffer.write(_renderExtensionType_partial_property_8(context5));
}
buffer.writeln();
buffer.write('''
</dl>
</section>''');
}
buffer.write('\n\n ');
buffer.write(_renderExtensionType_partial_instance_methods_8(context2));
buffer.write(_renderExtensionType_partial_instance_methods_9(context2));
buffer.write('\n ');
buffer.write(_renderExtensionType_partial_instance_operators_9(context2));
buffer.write(_renderExtensionType_partial_instance_operators_10(context2));
buffer.write('\n ');
buffer.write(_renderExtensionType_partial_static_properties_10(context2));
buffer.write(_renderExtensionType_partial_static_properties_11(context2));
buffer.write('\n ');
buffer.write(_renderExtensionType_partial_static_methods_11(context2));
buffer.write(_renderExtensionType_partial_static_methods_12(context2));
buffer.write('\n ');
buffer.write(_renderExtensionType_partial_static_constants_12(context2));
buffer.write(_renderExtensionType_partial_static_constants_13(context2));
buffer.writeln();
buffer.write('''

</div><!-- /.main-content -->

<div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
''');
buffer.write(_renderExtensionType_partial_search_sidebar_13(context0));
buffer.write(_renderExtensionType_partial_search_sidebar_14(context0));
buffer.writeln();
buffer.write('''
<h5>''');
Expand All @@ -920,7 +924,7 @@ String renderExtensionType<T extends ExtensionType>(
</div><!--/.sidebar-offcanvas-->

''');
buffer.write(_renderExtensionType_partial_footer_14(context0));
buffer.write(_renderExtensionType_partial_footer_15(context0));
buffer.writeln();
buffer.writeln();

Expand Down Expand Up @@ -2863,40 +2867,67 @@ String _renderExtensionType_partial_categorization_3(ExtensionType context1) =>
String _renderExtensionType_partial_documentation_4(ExtensionType context1) =>
_deduplicated_lib_templates_html__documentation_html(context1);

String _renderExtensionType_partial_container_annotations_5(
String _renderExtensionType_partial_interfaces_5(ExtensionType context1) {
final buffer = StringBuffer();
if (context1.hasPublicInterfaces == true) {
buffer.writeln();
buffer.write('''
<dt>Implemented types</dt>
<dd>
<ul class="comma-separated ''');
buffer.writeEscaped(context1.relationshipsClass);
buffer.write('''">''');
var context2 = context1.publicInterfaces;
for (var context3 in context2) {
buffer.writeln();
buffer.write('''
<li>''');
buffer.write(context3.linkedName);
buffer.write('''</li>''');
}
buffer.writeln();
buffer.write('''
</ul>
</dd>''');
}

return buffer.toString();
}

String _renderExtensionType_partial_container_annotations_6(
ExtensionType context1) =>
_deduplicated_lib_templates_html__container_annotations_html(context1);

String _renderExtensionType_partial_constructors_6(ExtensionType context1) =>
String _renderExtensionType_partial_constructors_7(ExtensionType context1) =>
_deduplicated_lib_templates_html__constructors_html(context1);

String _renderExtensionType_partial_property_7(Field context2) =>
String _renderExtensionType_partial_property_8(Field context2) =>
_deduplicated_lib_templates_html__property_html(context2);

String _renderExtensionType_partial_instance_methods_8(
String _renderExtensionType_partial_instance_methods_9(
ExtensionType context1) =>
_deduplicated_lib_templates_html__instance_methods_html(context1);

String _renderExtensionType_partial_instance_operators_9(
String _renderExtensionType_partial_instance_operators_10(
ExtensionType context1) =>
_deduplicated_lib_templates_html__instance_operators_html(context1);

String _renderExtensionType_partial_static_properties_10(
String _renderExtensionType_partial_static_properties_11(
ExtensionType context1) =>
_deduplicated_lib_templates_html__static_properties_html(context1);

String _renderExtensionType_partial_static_methods_11(ExtensionType context1) =>
String _renderExtensionType_partial_static_methods_12(ExtensionType context1) =>
_deduplicated_lib_templates_html__static_methods_html(context1);

String _renderExtensionType_partial_static_constants_12(
String _renderExtensionType_partial_static_constants_13(
ExtensionType context1) =>
_deduplicated_lib_templates_html__static_constants_html(context1);

String _renderExtensionType_partial_search_sidebar_13<T extends ExtensionType>(
String _renderExtensionType_partial_search_sidebar_14<T extends ExtensionType>(
ExtensionTypeTemplateData<T> context0) =>
_deduplicated_lib_templates_html__search_sidebar_html(context0);

String _renderExtensionType_partial_footer_14<T extends ExtensionType>(
String _renderExtensionType_partial_footer_15<T extends ExtensionType>(
ExtensionTypeTemplateData<T> context0) =>
_deduplicated_lib_templates_html__footer_html(context0);

Expand Down
20 changes: 20 additions & 0 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5508,6 +5508,13 @@ class _Renderer_ExtensionType extends RendererBase<ExtensionType> {
parent: r);
},
),
'hasPublicInterfaces': Property(
getValue: (CT_ c) => c.hasPublicInterfaces,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(c, remainingNames, 'bool'),
getBool: (CT_ c) => c.hasPublicInterfaces == true,
),
'inheritanceChain': Property(
getValue: (CT_ c) => c.inheritanceChain,
renderVariable: (CT_ c, Property<CT_> self,
Expand Down Expand Up @@ -5592,6 +5599,19 @@ class _Renderer_ExtensionType extends RendererBase<ExtensionType> {
parent: r, getters: _invisibleGetters['Kind']!);
},
),
'publicInterfaces': Property(
getValue: (CT_ c) => c.publicInterfaces,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'List<DefinedElementType>'),
renderIterable: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
return c.publicInterfaces.map((e) =>
_render_DefinedElementType(e, ast, r.template, sink,
parent: r));
},
),
'referenceChildren': Property(
getValue: (CT_ c) => c.referenceChildren,
renderVariable: (CT_ c, Property<CT_> self,
Expand Down
19 changes: 19 additions & 0 deletions lib/src/model/extension_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ class ExtensionType extends InheritingContainer with Constructable {
@override
bool get isSealed => false;

bool get hasPublicInterfaces => publicInterfaces.isNotEmpty;

@override
List<DefinedElementType> get publicInterfaces {
var interfaces = <DefinedElementType>[];
for (var interface in element.interfaces) {
var elementType =
modelBuilder.typeFrom(interface, library) as DefinedElementType;

if (elementType.modelElement.canonicalModelElement != null) {
interfaces.add(elementType);
continue;
}

// TODO(srawlins): Work through intermediate, private, interfaces.
}
return interfaces;
}

@override
late final List<Field> declaredFields = element.fields.map((field) {
Accessor? getter, setter;
Expand Down
1 change: 1 addition & 0 deletions lib/templates/html/extension_type.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{{ /representationType }}
</ul>
</dd>
{{ >interfaces }}
</dl>
{{ >container_annotations }}
</section>
Expand Down
Loading