Skip to content

Support inherited fields #107

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 2 commits into from
Feb 23, 2018
Merged

Support inherited fields #107

merged 2 commits into from
Feb 23, 2018

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Feb 21, 2018

No description provided.

@kevmoo kevmoo changed the title WIP: support subclasses support fields from subclasses Feb 23, 2018
@kevmoo kevmoo requested a review from natebosch February 23, 2018 17:23
@kevmoo kevmoo changed the title support fields from subclasses Support inherited fields Feb 23, 2018

/// Returns a list of all instance, [FieldElement] items for [element] and
/// super classes.
List<FieldElement> _getFields(ClassElement element) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] I have a personal vendetta against methods named get*. Maybe findFields or allFields?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to _listFields

var manager = new InheritanceManager(element.library);
var things = manager.getMembersInheritedFromClasses(element);

things.forEach((k, v) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't appear to use k at all and this loop has side effects. a for-in loop would be more idiomatic

for(final member in things.values) {
  assert(!member.isStatic)
  ...
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

var fieldsList = element.fields.where((e) => !e.isStatic).toList();

var manager = new InheritanceManager(element.library);
var things = manager.getMembersInheritedFromClasses(element);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

things is not descriptive. inheritedMembers maybe, or skip the variable since it's not used more than once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

var things = manager.getMembersInheritedFromClasses(element);

things.forEach((k, v) {
assert(!v.isStatic);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we asserting behavior of getMembersInheritedFromClasses? Do we need to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@kevmoo kevmoo merged commit 889e01e into master Feb 23, 2018
@kevmoo kevmoo deleted the super_subclasses branch February 23, 2018 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants