diff --git a/lib/src/generator/templates.aot_renderers_for_html.dart b/lib/src/generator/templates.aot_renderers_for_html.dart
index 69ba1ffb10..10cb3be3d9 100644
--- a/lib/src/generator/templates.aot_renderers_for_html.dart
+++ b/lib/src/generator/templates.aot_renderers_for_html.dart
@@ -4743,6 +4743,7 @@ String _deduplicated_lib_templates__accessor_getter_html(
buffer.write(''' ''');
buffer.write(context1.modelType.returnType.linkedName);
buffer.write('''
+ get
''');
buffer.write(
__deduplicated_lib_templates__accessor_getter_html_partial_name_summary_1(
@@ -4869,27 +4870,30 @@ String _deduplicated_lib_templates__accessor_setter_html(
__deduplicated_lib_templates__accessor_setter_html_partial_annotations_0(
context1));
buffer.writeln();
- buffer.write(''' void
- ''');
- buffer.write(
- __deduplicated_lib_templates__accessor_setter_html_partial_name_summary_1(
- context1));
- buffer.write('''(''');
+ buffer.write(''' set
+ ''');
+ buffer.writeEscaped(context1.definingCombo.name);
+ buffer.write('''
+ (''');
buffer.write(context1.linkedParamsNoMetadata);
buffer.write(''')
''');
buffer.write(
- __deduplicated_lib_templates__accessor_setter_html_partial_attributes_2(
+ __deduplicated_lib_templates__accessor_setter_html_partial_attributes_1(
context1));
buffer.writeln();
buffer.write('''
''');
buffer.write(
- __deduplicated_lib_templates__accessor_setter_html_partial_documentation_3(
+ __deduplicated_lib_templates__accessor_setter_html_partial_documentation_2(
context1));
buffer.write('\n ');
buffer.write(
- __deduplicated_lib_templates__accessor_setter_html_partial_source_code_4(
+ __deduplicated_lib_templates__accessor_setter_html_partial_source_code_3(
context1));
buffer.writeln();
buffer.write(''' ''');
@@ -4921,25 +4925,7 @@ String __deduplicated_lib_templates__accessor_setter_html_partial_annotations_0(
return buffer.toString();
}
-String
- __deduplicated_lib_templates__accessor_setter_html_partial_name_summary_1(
- Accessor context1) {
- final buffer = StringBuffer();
- if (context1.isConst) {
- buffer.write('''const ''');
- }
- buffer.write('''''');
- buffer.writeEscaped(context1.name);
- buffer.write('''''');
-
- return buffer.toString();
-}
-
-String __deduplicated_lib_templates__accessor_setter_html_partial_attributes_2(
+String __deduplicated_lib_templates__accessor_setter_html_partial_attributes_1(
Accessor context1) {
final buffer = StringBuffer();
if (context1.hasAttributes) {
@@ -4953,7 +4939,7 @@ String __deduplicated_lib_templates__accessor_setter_html_partial_attributes_2(
}
String
- __deduplicated_lib_templates__accessor_setter_html_partial_documentation_3(
+ __deduplicated_lib_templates__accessor_setter_html_partial_documentation_2(
Accessor context1) {
final buffer = StringBuffer();
if (context1.hasDocumentation) {
@@ -4969,7 +4955,7 @@ String
return buffer.toString();
}
-String __deduplicated_lib_templates__accessor_setter_html_partial_source_code_4(
+String __deduplicated_lib_templates__accessor_setter_html_partial_source_code_3(
Accessor context1) {
final buffer = StringBuffer();
if (context1.hasSourceCode) {
diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart
index ee6f309e2c..04f420abe2 100644
--- a/lib/src/generator/templates.runtime_renderers.dart
+++ b/lib/src/generator/templates.runtime_renderers.dart
@@ -6585,6 +6585,27 @@ class _Renderer_GetterSetterCombo extends RendererBase {
parent: r);
},
),
+ 'name': Property(
+ getValue: (CT_ c) => c.name,
+ renderVariable:
+ (CT_ c, Property self, List remainingNames) {
+ if (remainingNames.isEmpty) {
+ return self.getValue(c).toString();
+ }
+ var name = remainingNames.first;
+ var nextProperty =
+ _Renderer_String.propertyMap().getValue(name);
+ return nextProperty.renderVariable(
+ self.getValue(c) as String,
+ nextProperty,
+ [...remainingNames.skip(1)]);
+ },
+ isNullValue: (CT_ c) => false,
+ renderValue: (CT_ c, RendererBase r,
+ List ast, StringSink sink) {
+ _render_String(c.name, ast, r.template, sink, parent: r);
+ },
+ ),
'oneLineDoc': Property(
getValue: (CT_ c) => c.oneLineDoc,
renderVariable:
@@ -16013,6 +16034,7 @@ const _invisibleGetters = {
'isPublic',
'linkedParamsNoMetadata',
'modelType',
+ 'name',
'oneLineDoc',
'parameters',
'readOnly',
diff --git a/lib/src/model/getter_setter_combo.dart b/lib/src/model/getter_setter_combo.dart
index 697b9097fa..3c0950e20b 100644
--- a/lib/src/model/getter_setter_combo.dart
+++ b/lib/src/model/getter_setter_combo.dart
@@ -56,6 +56,11 @@ mixin GetterSetterCombo on ModelElement {
bool get isInherited;
+ @override
+ // Food for mustachio; because this is a mixin, mustachio can't figure out
+ // that this implicitly has a `name` property.
+ String get name;
+
@override
String get fileName => isConst ? '$name-constant.html' : '$name.html';
diff --git a/lib/templates/_accessor_getter.html b/lib/templates/_accessor_getter.html
index ac0cf538df..bced920ae0 100644
--- a/lib/templates/_accessor_getter.html
+++ b/lib/templates/_accessor_getter.html
@@ -1,9 +1,9 @@
{{ #getter }}
-
{{ >annotations }}
{{{ modelType.returnType.linkedName }}}
+ get
{{ >name_summary }}
{{ >attributes }}
diff --git a/lib/templates/_accessor_setter.html b/lib/templates/_accessor_setter.html
index 5b7c89c22b..4365ee2843 100644
--- a/lib/templates/_accessor_setter.html
+++ b/lib/templates/_accessor_setter.html
@@ -3,8 +3,9 @@
{{ >annotations }}
- void
- {{ >name_summary }}({{{ linkedParamsNoMetadata }}})
+ set
+ {{ definingCombo.name }}
+ ({{{ linkedParamsNoMetadata }}})
{{ >attributes }}
diff --git a/test/templates/field_test.dart b/test/templates/field_test.dart
index 34c9dd8148..15519a85af 100644
--- a/test/templates/field_test.dart
+++ b/test/templates/field_test.dart
@@ -91,6 +91,93 @@ extension type ET(
);
}
+ void test_getter_signature() async {
+ await createPackageWithLibrary('''
+class C {
+ int get f1 => 1;
+}
+''');
+ var f1Lines = readLines(['lib', 'C', 'f1.html']);
+ f1Lines.expectMainContentContainsAllInOrder(
+ [
+ matches('f1 property'),
+ matches(''),
+ matches('int'),
+ matches('get'),
+ matches('f1'),
+ ],
+ );
+ }
+
+ void test_getter_overridingProperty_signature() async {
+ await createPackageWithLibrary('''
+class C {
+ int f1 = 0;
+}
+class D extends C {
+ @override
+ int get f1 => 1;
+}
+''');
+ var f1Lines = readLines(['lib', 'D', 'f1.html']);
+ f1Lines.expectMainContentContainsAllInOrder(
+ [
+ matches('f1 property'),
+ matches(''),
+ matches('int'),
+ matches('get'),
+ matches('f1'),
+ ],
+ );
+ }
+
+ void test_setter_signature() async {
+ await createPackageWithLibrary('''
+class C {
+ set f1(int value) {}
+}
+''');
+ var f1Lines = readLines(['lib', 'C', 'f1.html']);
+ f1Lines.expectMainContentContainsAllInOrder(
+ [
+ matches(''),
+ matches('set'),
+ matches('f1'),
+ matches(r'\('
+ ''
+ 'int '
+ 'value'
+ r'\)'
+ ''),
+ ],
+ );
+ }
+
+ void test_setter_overridingProperty_signature() async {
+ await createPackageWithLibrary('''
+class C {
+ int f1 = 0;
+}
+class D extends C {
+ set f1(int value) {}
+}
+''');
+ var f1Lines = readLines(['lib', 'D', 'f1.html']);
+ f1Lines.expectMainContentContainsAllInOrder(
+ [
+ matches(''),
+ matches('set'),
+ matches('f1'),
+ matches(r'\('
+ ''
+ 'int '
+ 'value'
+ r'\)'
+ ''),
+ ],
+ );
+ }
+
// TODO(srawlins): Add rendering tests:
// * how inherited fields look on subclass page ('inherited' feature)
// * static fields