@@ -8,6 +8,7 @@ import 'package:dartdoc/src/element_type.dart';
8
8
import 'package:dartdoc/src/model/extension_target.dart' ;
9
9
import 'package:dartdoc/src/model/model.dart' ;
10
10
import 'package:dartdoc/src/model_utils.dart' as model_utils;
11
+ import 'package:meta/meta.dart' ;
11
12
import 'package:quiver/iterables.dart' as quiver;
12
13
13
14
/// A [Container] defined with a `class` declaration in Dart.
@@ -20,32 +21,43 @@ import 'package:quiver/iterables.dart' as quiver;
20
21
class Class extends Container
21
22
with TypeParameters , Categorization , ExtensionTarget
22
23
implements EnclosedElement {
23
- List <DefinedElementType > mixins;
24
- DefinedElementType supertype;
25
- List <DefinedElementType > _interfaces;
26
- List <Operator > _inheritedOperators;
27
- List <Method > _inheritedMethods;
24
+ // TODO(srawlins): To make final, remove public getter, setter, rename to be
25
+ // public, and add `final` modifier.
26
+ List <DefinedElementType > _mixins;
27
+
28
+ List <DefinedElementType > get mixins => _mixins;
29
+
30
+ @Deprecated ('Field intended to be final; setter will be removed as early as '
31
+ 'Dartdoc 1.0.0' )
32
+ set mixins (List <DefinedElementType > value) => _mixins = value;
33
+
34
+ // TODO(srawlins): To make final, remove public getter, setter, rename to be
35
+ // public, and add `final` modifier.
36
+ DefinedElementType _supertype;
37
+
38
+ DefinedElementType get supertype => _supertype;
39
+
40
+ @Deprecated ('Field intended to be final; setter will be removed as early as '
41
+ 'Dartdoc 1.0.0' )
42
+ set supertype (DefinedElementType value) => _supertype = value;
43
+
44
+ final List <DefinedElementType > _interfaces;
28
45
29
46
Class (ClassElement element, Library library, PackageGraph packageGraph)
30
- : super (element, library, packageGraph) {
47
+ : _mixins = element.mixins
48
+ .map <DefinedElementType >(
49
+ (f) => ElementType .from (f, library, packageGraph))
50
+ .where ((mixin ) => mixin != null )
51
+ .toList (growable: false ),
52
+ _supertype = element.supertype? .element? .supertype == null
53
+ ? null
54
+ : ElementType .from (element.supertype, library, packageGraph),
55
+ _interfaces = element.interfaces
56
+ .map <DefinedElementType >(
57
+ (f) => ElementType .from (f, library, packageGraph))
58
+ .toList (growable: false ),
59
+ super (element, library, packageGraph) {
31
60
packageGraph.specialClasses.addSpecial (this );
32
- mixins = element.mixins
33
- .map ((f) {
34
- DefinedElementType t = ElementType .from (f, library, packageGraph);
35
- return t;
36
- })
37
- .where ((mixin ) => mixin != null )
38
- .toList (growable: false );
39
-
40
- if (element.supertype != null &&
41
- element.supertype.element.supertype != null ) {
42
- supertype = ElementType .from (element.supertype, library, packageGraph);
43
- }
44
-
45
- _interfaces = element.interfaces
46
- .map ((f) =>
47
- ElementType .from (f, library, packageGraph) as DefinedElementType )
48
- .toList (growable: false );
49
61
}
50
62
51
63
Constructor _defaultConstructor;
@@ -60,6 +72,7 @@ class Class extends Container
60
72
Iterable <Method > get instanceMethods =>
61
73
quiver.concat ([super .instanceMethods, inheritedMethods]);
62
74
75
+ // Whether all instance methods are inherited, used in mustache templates.
63
76
bool get publicInheritedInstanceMethods =>
64
77
instanceMethods.every ((f) => f.isInherited);
65
78
@@ -87,10 +100,10 @@ class Class extends Container
87
100
allModelElements.where ((e) => e.isCanonical).toList ());
88
101
}
89
102
90
- Iterable <Constructor > get constructors => element.constructors.map ((e) {
91
- return ModelElement .from (e, library, packageGraph) as Constructor ;
92
- });
103
+ Iterable <Constructor > get constructors => element.constructors
104
+ .map ((e) => ModelElement .from (e, library, packageGraph) as Constructor );
93
105
106
+ @visibleForTesting
94
107
Iterable <Constructor > get publicConstructors =>
95
108
model_utils.filterNonPublic (constructors);
96
109
@@ -112,6 +125,7 @@ class Class extends Container
112
125
return kind;
113
126
}
114
127
128
+ // Whether any constructors are public, used in mustache templates.
115
129
bool get hasPublicConstructors => publicConstructorsSorted.isNotEmpty;
116
130
117
131
List <Constructor > _publicConstructorsSorted;
@@ -151,6 +165,7 @@ class Class extends Container
151
165
model_utils.findCanonicalFor (packageGraph.implementors[href] ?? []));
152
166
}
153
167
168
+ /*lazy final*/ List <Method > _inheritedMethods;
154
169
Iterable <Method > get inheritedMethods {
155
170
if (_inheritedMethods == null ) {
156
171
_inheritedMethods = < Method > [];
@@ -177,6 +192,7 @@ class Class extends Container
177
192
178
193
bool get hasPublicInheritedMethods => publicInheritedMethods.isNotEmpty;
179
194
195
+ /*lazy final*/ List <Operator > _inheritedOperators;
180
196
Iterable <Operator > get inheritedOperators {
181
197
if (_inheritedOperators == null ) {
182
198
_inheritedOperators = [];
@@ -227,9 +243,14 @@ class Class extends Container
227
243
}
228
244
229
245
/// Returns true if [other] is a parent class for this class.
230
- bool isInheritingFrom ( covariant Class other) =>
246
+ bool _isInheritingFrom ( Class other) =>
231
247
superChain.map ((et) => (et.element as Class )).contains (other);
232
248
249
+ @Deprecated (
250
+ 'Public method intended to be private; will be removed as early as '
251
+ 'Dartdoc 1.0.0' )
252
+ bool isInheritingFrom (Class other) => _isInheritingFrom (other);
253
+
233
254
@override
234
255
String get kind => 'class' ;
235
256
@@ -417,7 +438,7 @@ class Class extends Container
417
438
// to this class on the inheritance chain.
418
439
if (setter.enclosingElement is Class &&
419
440
(setter.enclosingElement as Class )
420
- .isInheritingFrom (getter.enclosingElement)) {
441
+ ._isInheritingFrom (getter.enclosingElement)) {
421
442
f = setterElement.variable;
422
443
} else {
423
444
f = getterElement.variable;
0 commit comments