Skip to content

Add 'override' to features list #1798

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 8 commits into from
Oct 16, 2018
Merged

Add 'override' to features list #1798

merged 8 commits into from
Oct 16, 2018

Conversation

jcollins-g
Copy link
Contributor

Fixes #981.

Adds the text 'override' to the features list if the class member is a declared override of the parent.

screen shot 2018-10-15 at 12 07 30 pm

Also handles complex cases involving fields and getter/setter declarations:
screen shot 2018-10-15 at 12 09 27 pm

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Oct 15, 2018
@jcollins-g jcollins-g requested review from devoncarew and pq October 15, 2018 19:10
@devoncarew
Copy link
Member

override sounds a little odd in this context. inherited reads better; perhaps the analog for override would be overridden from parent? overrides parent?

It may additionally make sense to change it from override since I don't think this is the same as having an @override annotation; one is user added and the other is programmatically calculated.

Should we not show the inherited text for nodes that display override? It seems like the later implies the former.

I'll review now...

Copy link
Member

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

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

Changes look good!

It may additionally make sense to change it from override since I don't think this is the same as having an @OverRide annotation; one is user added and the other is programmatically calculated.

It looks like you're handling this - removing any associated @override annotation, and only displaying the calculated override.

I thought about it a bit more, and couldn't come up with better text than override. It might be worth thinking about whether you want to drop inherited when displaying override for a node.

if (_isOverride == null) {
// The canonical version of the enclosing element (not canonicalEnclosingElement,
// as that is the element enclosing the canonical version of this element,
// two different things. Defaults to the enclosing element.
Copy link
Member

Choose a reason for hiding this comment

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

nit: opening paran not closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@jcollins-g
Copy link
Contributor Author

@kwalrath Any suggestions on language? I'm not a huge fan of "override" here. I agree with Devon that it feels wrong, but I also don't like the alternatives we've thought of so far.

@kwalrath
Copy link
Contributor

"overridden" makes more sense to me, since it's parallel to "inherited" and doesn't sound like a command (you must override this).

@devoncarew
Copy link
Member

Yeah, but in this case it's the parent element which is overridden. Perhaps strict semantics aren't necessary here though, in favor of brevity.

@jcollins-g
Copy link
Contributor Author

@kwalrath Hmmm. We're really trying to briefly say "This member is inherited from some other class" or "This member overrides a member in some other class" for overrides.

I'm a little concerned about "overridden" because that seems to be common usage for the wrong piece (the part in the other class being, well, overridden).

https://en.wikipedia.org/wiki/Method_overriding
https://en.wikipedia.org/wiki/Method_overriding#/media/File:Method_overriding_in_subclass.svg

"Overriding" is yet another possibility, but doesn't seem that much better than "override" to me. Despite some discomfort, override does have the advantage of mirroring the Dart annotation for the same thing.

Copy link
Contributor Author

@jcollins-g jcollins-g left a comment

Choose a reason for hiding this comment

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

I have tried to deal with the inherited+override possibility via an assert which fires in the event we ever declare something with both inherited and override at the same time. I've run with the assert enabled over all of Flutter with the Dart SDK and all the pub packages it documents and haven't found any cases where we do that.

Fields with split-inheritance are handled by indicating the setter/getter is inherited/overriding.

if (_isOverride == null) {
// The canonical version of the enclosing element (not canonicalEnclosingElement,
// as that is the element enclosing the canonical version of this element,
// two different things. Defaults to the enclosing element.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@jcollins-g jcollins-g merged commit 8561a56 into master Oct 16, 2018
@jcollins-g jcollins-g deleted the override-feature branch October 16, 2018 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants