Skip to content
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

Move the filterNonDocumented and filterNonPublic functions as extension getters #3699

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented Mar 1, 2024

filterNonPublic becomes an extension getter, wherePublic, and filterNonDocumented becomes an extension getter, whereDocumented.

Nameable now implements Privacy. Privacy is now an abstract interface class.

Changing all the call sites highlights a number of ModelElement getters that are superfluous. For example, Container.publicInstanceMethods. This was a getter that now boils down to instanceMethods.wherePublic, and it really is unneccessary to keep this; there are many such methods that are removed here:

  • Container: publicInstanceMethods, publicInstanceOperators, publicInstanceFields, publicConstantFields,
  • InheritingContainer: publicSuperChain, publicInheritedFields, publicInheritedMethods,
  • LibraryContainer: publicLibraries,
  • Package: documentedCategories,
  • PackageGraph: documentedExtensions,
  • TopLevelContainer: publicClasses, publicExtensions, publicExtensionTypes, publicConstants, publicEnums, _publicExceptions, publicFunctions, publicMixins, publicProperties, publicTypedefs.

Additionally, this change highlights some small inefficiency in some hasX methods. For example, hasPublicInstanceMethods used to enumerate all of the public instance methods, then ask if the list is empty. Now we can ask if any of the instanceMethods are public.

  • Container: hasPublicInstanceMethods, hasPublicInstanceOperators, hasPublicInstanceFields, hasPublicConstantFields, hasPublicVariableStaticFields, hasPublicStaticMethods, hasPublicEnumValues,
  • InheritingContainer: hasPublicInheritedMethods, hasPublicSuperChainReversed,
  • MixedInTypes: hasPublicMixedInTypes,
  • LibraryContainer: hasPublicLibraries,
  • Package: hasDocumentedCategories,
  • TopLevelContainer: hasPublicClasses, hasPublicExtensions, hasPublicExtensionTypes, hasPublicConstants, hasPublicEnums, hasPublicExceptions, hasPublicFunctions,hasPublicMixins, hasPublicProperties, hasPublicTypedefs.

Because the field InheritingContaier.publicSuperChain is removed, I change superChain from a getter to a field, sort of the point of caching.

  • Thanks for your contribution! Please replace this text with a description of what this PR is changing or adding and why, list any relevant issues, and review the contribution guidelines below.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

…ension getters

`filterNonPublic` becomes an extension getter, `wherePublic`, and
`filterNonDocumented` becomes an extension getter, `whereDocumented`.

Nameable now implements Privacy. Privacy is now an abstract interface class.

Changing all the call sites highlights a number of ModelElement getters that
are superfluous. For example, `Container.publicInstanceMethods`. This was a
getter that now boils down to `instanceMethods.wherePublic`, and it really is
unneccessary to keep this; there are many such methods that are removed here:

* Container: `publicInstanceMethods`, `publicInstanceOperators`, `publicInstanceFields`,
  `publicConstantFields`,
* InheritingContainer: `publicSuperChain`, `publicInheritedFields`, `publicInheritedMethods`,
* LibraryContainer: `publicLibraries`,
* Package: `documentedCategories`,
* PackageGraph: `documentedExtensions`,
* TopLevelContainer: `publicClasses`, `publicExtensions`,
  `publicExtensionTypes`, `publicConstants`, `publicEnums`,
  `_publicExceptions`, `publicFunctions`, `publicMixins`, `publicProperties`,
  `publicTypedefs`.

Additionally, this change highlights some small inefficiency in some `hasX`
methods. For example, `hasPublicInstanceMethods` used to enumerate all of the
public instance methods, then ask if the list is empty. Now we can ask if `any`
of the `instanceMethods` are `public`.

* Container: `hasPublicInstanceMethods`, `hasPublicInstanceOperators`,
  `hasPublicInstanceFields`, `hasPublicConstantFields`,
  `hasPublicVariableStaticFields`, `hasPublicStaticMethods`,
  `hasPublicEnumValues`,
* InheritingContainer: `hasPublicInheritedMethods`,
  `hasPublicSuperChainReversed`,
* MixedInTypes: `hasPublicMixedInTypes`,
* LibraryContainer: `hasPublicLibraries`,
* Package: `hasDocumentedCategories`,
* TopLevelContainer: `hasPublicClasses`, `hasPublicExtensions`,
  `hasPublicExtensionTypes`, `hasPublicConstants`, `hasPublicEnums`,
  `hasPublicExceptions`, `hasPublicFunctions`,`hasPublicMixins`,
  `hasPublicProperties`, `hasPublicTypedefs`.

Because the field `InheritingContaier.publicSuperChain` is removed, I change
`superChain` from a getter to a field, sort of the point of caching.
@srawlins srawlins merged commit 7b50ea4 into dart-lang:main Mar 7, 2024
9 checks passed
@srawlins srawlins deleted the utils-to-extensions branch March 7, 2024 20:34
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Mar 11, 2024
Revisions updated by `dart tools/rev_sdk_deps.dart`.

async (https://github.com/dart-lang/async/compare/6cdbc41..1556660):
  1556660  2024-03-07  Kevin Moore  Test on wasm (dev) and JS (dart-lang/async#269)

dartdoc (https://github.com/dart-lang/dartdoc/compare/0de8aff..ef990e7):
  ef990e79  2024-03-10  dependabot[bot]  Bump actions/cache from 4.0.0 to 4.0.1 (dart-lang/dartdoc#3700)
  962d68fe  2024-03-08  Sam Rawlins  Convert many fields on Container and TopLevelContainer to getters (dart-lang/dartdoc#3710)
  353b426c  2024-03-08  Kallen Tu  Remove unresolved-export warning. (dart-lang/dartdoc#3711)
  cdcbf6d8  2024-03-08  Kallen Tu  Change mixin implements and remove unused Extendable. (dart-lang/dartdoc#3709)
  da7071d5  2024-03-08  Sam Rawlins  Display an extension's extended type in a few places. (dart-lang/dartdoc#3708)
  3d56168d  2024-03-08  Sam Rawlins  Add some help messages to tool/task.dart (dart-lang/dartdoc#3707)
  4f849678  2024-03-07  Sam Rawlins  Remove the TypeImplementing mixin; unnecessary (dart-lang/dartdoc#3705)
  7b50ea4a  2024-03-07  Sam Rawlins  Move the `filterNonDocumented` and `filterNonPublic` functions as extension getters (dart-lang/dartdoc#3699)

http (https://github.com/dart-lang/http/compare/8d3c647..8da6e0e):
  8da6e0e  2024-03-08  Derek Xu  [package:http_profile] Store request and response bodies in the backing map as lists instead of streams (dart-lang/http#1154)

markdown (https://github.com/dart-lang/markdown/compare/1ca5166..9c6b1af):
  9c6b1af  2024-03-10  Jonas Finnemann Jensen  Run a periodic crash-test (dart-lang/markdown#590)
  1654801  2024-03-08  Zhiguang Chen  Add single tilde support to `StrikethroughSyntax` (dart-lang/markdown#595)

test (https://github.com/dart-lang/test/compare/7724aab..ba64bbb):
  ba64bbba  2024-03-07  Nate Bosch  Let the IsolateChannel close the ReceivePort (dart-lang/test#2196)

Change-Id: I5fad5442fe1a183707888276264eb9c47cc3c96f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356780
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
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