List<Field>
inheritedProperties
Source
List<Field> get inheritedProperties {
if (_inheritedProperties != null) return _inheritedProperties;
Map<String, ExecutableElement> cmap =
library.inheritanceManager.getMembersInheritedFromClasses(element);
Map<String, ExecutableElement> imap =
library.inheritanceManager.getMembersInheritedFromInterfaces(element);
_inheritedProperties = [];
List<ExecutableElement> values = [];
Set<String> uniqueNames = new Set();
instanceProperties.forEach((f) {
if (f._setter != null) uniqueNames.add(f._setter.name);
if (f._getter != null) uniqueNames.add(f._getter.name);
});
for (String key in cmap.keys) {
// XXX: if we care about showing a hierarchy with our inherited methods,
// then don't do this
if (uniqueNames.contains(key)) continue;
uniqueNames.add(key);
values.add(cmap[key]);
}
for (String key in imap.keys) {
// XXX: if we care about showing a hierarchy with our inherited methods,
// then don't do this
if (uniqueNames.contains(key)) continue;
uniqueNames.add(key);
values.add(imap[key]);
}
values
.removeWhere((it) => instanceProperties.any((i) => it.name == i.name));
for (var value in values) {
if (value != null &&
value is PropertyAccessorElement &&
isPublic(value) &&
value.enclosingElement != null) {
// This seems to be here to deal with half-field inheritance, where
// we inherit a getter but not a setter, or vice-versa. (Or if a parent
// class has the same trouble). In that case, just drop any duplicate
// names we see. This probably results in bugs.
// TODO(jcollins-g): deal with half-inherited fields better
var e = value.variable;
if (instanceProperties.any((f) => f.element.name == e.name)) continue;
if (_inheritedProperties.any((f) => f.element.name == e.name)) continue;
if (!package.isDocumented(value.enclosingElement)) {
Field f = new ModelElement.from(e, library, enclosingClass: this);
_inheritedProperties.add(f);
_genPageProperties.add(f);
} else {
_inheritedProperties
.add(new ModelElement.from(e, library, enclosingClass: this));
}
}
}
_inheritedProperties.sort(byName);
return _inheritedProperties;
}