Skip to content

Support abstract fields #2329

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

Merged
merged 1 commit into from
Sep 3, 2020
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
8 changes: 3 additions & 5 deletions lib/src/generator/template_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,21 @@ class PropertyTemplateData extends TemplateData<Field> {

@override
String get title =>
'${property.name} $_type - ${container.name} ${containerDesc} - '
'${property.name} ${property.kind} - ${container.name} ${containerDesc} - '
'${library.name} library - Dart API';
@override
String get layoutTitle =>
_layoutTitle(property.name, _type, property.isDeprecated);
_layoutTitle(property.name, property.fullkind, property.isDeprecated);
@override
String get metaDescription =>
'API docs for the ${property.name} $_type from the '
'API docs for the ${property.name} ${property.kind} from the '
'${container.name} ${containerDesc}, for the Dart programming language.';
@override
List<Documentable> get navLinks => [packageGraph.defaultPackage, library];
@override
List<Documentable> get navLinksWithGenerics => [container];
@override
String get htmlBase => '../../';

String get _type => property.isConst ? 'constant' : 'property';
}

class TypedefTemplateData extends TemplateData<Typedef> {
Expand Down
5 changes: 5 additions & 0 deletions lib/src/model/field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class Field extends ModelElement
return allAnnotations;
}

String get fullkind {
if (field.isAbstract) return 'abstract $kind';
return kind;
}

@override
Set<String> get features {
var allFeatures = super.features..addAll(comboFeatures);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
sdk: '>=2.7.0 <3.0.0'

dependencies:
analyzer: ^0.39.16
analyzer: ^0.39.17
args: '>=1.5.0 <2.0.0'
collection: ^1.2.0
cli_util: '>=0.1.4 <0.3.0'
Expand Down
8 changes: 7 additions & 1 deletion test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ void main() {
expect(Cat.fullkind, 'abstract class');
});

test('class title has no abstract keyword', () {
test('class title has no abstract keyword', () {
expect(Dog.fullkind, 'class');
});

Expand Down Expand Up @@ -3029,6 +3029,12 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
withGenericSub.inheritedFields.where((p) => p.name == 'prop').length,
equals(1));
});

test('has abstract kind', () {
Field abstractField = UnusualProperties.allModelElements
.firstWhere((e) => e.name == 'abstractProperty');
expect(abstractField.fullkind, 'abstract property');
});
});

group('Accessor', () {
Expand Down
3 changes: 3 additions & 0 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ class ClassWithUnusualProperties extends ImplicitProperties {
/// This property has some docs, too.
final Set finalProperty = Set();

/// This property has docs.
abstract Set abstractProperty;

Map implicitReadWrite;

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