Skip to content

Commit 44b5afc

Browse files
committed
Fix duplicated '@OverRide' and '@deprecated' features.
These features were accidentally duplicated in dart-lang#2313.
1 parent a6900d9 commit 44b5afc

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lib/src/model/model_element.dart

+17-12
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ abstract class ModelElement extends Canonicalization
403403
// akin to source_gen's Reviver, in order to link to inner components. For
404404
// example, in `@Foo(const Bar(), baz: <Baz>[Baz.one, Baz.two])`, link to
405405
// `Foo`, `Bar`, `Baz`, `Baz.one`, and `Baz.two`.
406-
List<String> annotationsFromMetadata(List<ElementAnnotation> md) {
406+
List<String> annotationsFromMetadata(Iterable<ElementAnnotation> md) {
407407
var annotationStrings = <String>[];
408408
if (md == null) return annotationStrings;
409409
for (var a in md) {
@@ -522,21 +522,26 @@ abstract class ModelElement extends Canonicalization
522522
.split(locationSplitter)
523523
.where((s) => s.isNotEmpty));
524524

525-
Set<String> get features {
526-
var allFeatures = <String>{...annotations};
527-
525+
static final Set<String> _specialFeatures = {
528526
// Replace the @override annotation with a feature that explicitly
529527
// indicates whether an override has occurred.
530-
allFeatures.remove('@override');
531-
528+
'override',
532529
// Drop the plain "deprecated" annotation; that's indicated via
533530
// strikethroughs. Custom @Deprecated() will still appear.
534-
allFeatures.remove('@deprecated');
535-
// const and static are not needed here because const/static elements get
536-
// their own sections in the doc.
537-
if (isFinal) allFeatures.add('final');
538-
if (isLate) allFeatures.add('late');
539-
return allFeatures;
531+
'deprecated'
532+
};
533+
534+
Set<String> get features {
535+
return {
536+
...annotationsFromMetadata(element.metadata
537+
.where((e) => !_specialFeatures.contains(e.element?.name))),
538+
// 'const' and 'static' are not needed here because 'const' and 'static'
539+
// elements get their own sections in the doc.
540+
if (isFinal)
541+
'final',
542+
if (isLate)
543+
'late',
544+
};
540545
}
541546

542547
String get featuresAsString {

0 commit comments

Comments
 (0)