Skip to content

Simplify InheritingContainer wrt inherited elements #4059

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 1 commit into from
May 28, 2025

Conversation

srawlins
Copy link
Member

While working with analyzer's InheritanceManager3, I noticed there was a fair bit of code in dartdoc's InheritingContainer that could be simplified. The _inheritedElements field is relied on by inheritedMethods, inheritedOperators, and allFields. It performs some calculations to come up with the collection of inherited elements using its own homegrown dartdoc logic, but this logic exists in the analyzer APIs on InterfaceElement. We can basically replace this field with access to element.inheritedElements.

While investigating, I found that I could make a few members @visibleForTesting: inheritedMethods, inheritedOperators. Also allFields can be made private. And Enum.hasPublicEnumValues can be removed, as it is the same as the super implementation. This leads to all of the deleted code in templates.runtime_renderers.dart.

While working with analyzer's InheritanceManager3, I noticed there was a fair
bit of code in dartdoc's InheritingContainer that could be simplified. The
`_inheritedElements` field is relied on by `inheritedMethods`,
`inheritedOperators`, and `allFields`. It performs some calculations to come up
with the collection of inherited elements using its own homegrown dartdoc
logic, but this logic exists in the analyzer APIs on `InterfaceElement`. We can
basically replace this field with access to `element.inheritedElements`.

While investigating, I found that I could make a few members
`@visibleForTesting`: `inheritedMethods`, `inheritedOperators`. Also
`allFields` can be made private. And `Enum.hasPublicEnumValues` can be removed,
as it is the same as the super implementation. This leads to all of the deleted
code in `templates.runtime_renderers.dart`.
@srawlins srawlins force-pushed the no-inherited-elements branch from 276d85c to bd4eacb Compare May 27, 2025 16:28
Copy link
Contributor

@szakarias szakarias left a comment

Choose a reason for hiding this comment

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

LGTM

@srawlins srawlins merged commit a4fb766 into dart-lang:main May 28, 2025
11 checks passed
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.

3 participants