Skip to content

Commit 84de3a1

Browse files
authored
Support abstract fields (#2329)
1 parent f295391 commit 84de3a1

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

lib/src/generator/template_data.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,23 +335,21 @@ class PropertyTemplateData extends TemplateData<Field> {
335335

336336
@override
337337
String get title =>
338-
'${property.name} $_type - ${container.name} ${containerDesc} - '
338+
'${property.name} ${property.kind} - ${container.name} ${containerDesc} - '
339339
'${library.name} library - Dart API';
340340
@override
341341
String get layoutTitle =>
342-
_layoutTitle(property.name, _type, property.isDeprecated);
342+
_layoutTitle(property.name, property.fullkind, property.isDeprecated);
343343
@override
344344
String get metaDescription =>
345-
'API docs for the ${property.name} $_type from the '
345+
'API docs for the ${property.name} ${property.kind} from the '
346346
'${container.name} ${containerDesc}, for the Dart programming language.';
347347
@override
348348
List<Documentable> get navLinks => [packageGraph.defaultPackage, library];
349349
@override
350350
List<Documentable> get navLinksWithGenerics => [container];
351351
@override
352352
String get htmlBase => '../../';
353-
354-
String get _type => property.isConst ? 'constant' : 'property';
355353
}
356354

357355
class TypedefTemplateData extends TemplateData<Typedef> {

lib/src/model/field.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ class Field extends ModelElement
115115
return allAnnotations;
116116
}
117117

118+
String get fullkind {
119+
if (field.isAbstract) return 'abstract $kind';
120+
return kind;
121+
}
122+
118123
@override
119124
Set<String> get features {
120125
var allFeatures = super.features..addAll(comboFeatures);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: '>=2.7.0 <3.0.0'
88

99
dependencies:
10-
analyzer: ^0.39.16
10+
analyzer: ^0.39.17
1111
args: '>=1.5.0 <2.0.0'
1212
collection: ^1.2.0
1313
cli_util: '>=0.1.4 <0.3.0'

test/end2end/model_test.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ void main() {
16711671
expect(Cat.fullkind, 'abstract class');
16721672
});
16731673

1674-
test('class title has no abstract keyword', () {
1674+
test('class title has no abstract keyword', () {
16751675
expect(Dog.fullkind, 'class');
16761676
});
16771677

@@ -3043,6 +3043,12 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
30433043
withGenericSub.inheritedFields.where((p) => p.name == 'prop').length,
30443044
equals(1));
30453045
});
3046+
3047+
test('has abstract kind', () {
3048+
Field abstractField = UnusualProperties.allModelElements
3049+
.firstWhere((e) => e.name == 'abstractProperty');
3050+
expect(abstractField.fullkind, 'abstract property');
3051+
});
30463052
});
30473053

30483054
group('Accessor', () {

testing/test_package/lib/fake.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ class ClassWithUnusualProperties extends ImplicitProperties {
548548
/// This property has some docs, too.
549549
final Set finalProperty = Set();
550550

551+
/// This property has docs.
552+
abstract Set abstractProperty;
553+
551554
Map implicitReadWrite;
552555

553556
/// Hey there, more things not to warn about: [f], [x], or [q].

0 commit comments

Comments
 (0)