-
Notifications
You must be signed in to change notification settings - Fork 118
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
Combine the two implementations of "library canonicalization" #3781
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
srawlins
force-pushed
the
one-lib-canonical
branch
from
June 7, 2024 14:02
67bbf1d
to
4bef375
Compare
I was shocked to find that we had two mechanisms for determining an element's "canonical library": `ModelElement.canonicalLibrary` and a `PackageGraph._findCanonicalLibraryFor`. They were not quite the same implementation, but the differences turn out to be uninteresting; the two implementations can be combined. This change removes `PackageGraph._findCanonicalLibraryFor`. This implementation was only used in the package graph to find the canonical element for a given element. That code can now just use `ModelElement.canonicalLibrary`. It requires a fair bit of refactoring all over: * `PackageGraph.findCanonicalModelElementFor` previously accepted an analyzer Element, instead of a ModelElement, but almost all of the call sites used `foo.element` or some other expression that could easily be replaced with an access to a ModelElement instead of the correlated Element. * Document `ModelElement.definingLibrary`, `ModelElement.canonicalLibrary`, `ModelElement._searchForCanonicalLibrary`. * Simplify `ContainerMember.computeCanonicalEnclosingContainer` to stop unnecessarily special-casing extensions and extension types. * Simplify lookup component of `ModelElement._searchForCanonicalLibrary`. * Simplity `ContainerMember.referenceGrandparentOverrides` to not use `sync*`. * Move the top-level `findCanonicalFor` function out of `model_utils.dart` and into `inheriting_container.dart`, the only code that uses it anymore.
srawlins
force-pushed
the
one-lib-canonical
branch
from
June 7, 2024 14:30
4bef375
to
8c8db77
Compare
CC @dart-lang/analyzer-team |
bwilkerson
approved these changes
Jun 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have the context for this, but assuming that the tests are adequate to catch any user-visible changes this might have caused, lgtm.
copybara-service bot
pushed a commit
to dart-lang/sdk
that referenced
this pull request
Jun 13, 2024
…ser, path, shelf, test, webdev Revisions updated by `dart tools/rev_sdk_deps.dart`. async (https://github.com/dart-lang/async/compare/4073129..a004370): a004370 2024-06-10 Kevin Moore Bump min SDK, tighten dependencies, test wasm on 3.4 (dart-archive/async#277) convert (https://github.com/dart-lang/convert/compare/70940e3..0c9eab7): 0c9eab7 2024-06-10 Kevin Moore latest lints, require Dart 3.4 (dart-archive/convert#107) crypto (https://github.com/dart-lang/crypto/compare/7a9428a..813e35e): 813e35e 2024-06-10 Kevin Moore Update min SDK, test wasm on 3.4 (dart-archive/crypto#174) dartdoc (https://github.com/dart-lang/dartdoc/compare/3decf1e..14d33d3): 14d33d3a 2024-06-12 Sam Rawlins Fix referencing an aliased type parameter. (dart-lang/dartdoc#3784) 12d271a5 2024-06-10 Sam Rawlins Combine the two implementations of "library canonicalization" (dart-lang/dartdoc#3781) ca61935e 2024-06-10 Sam Rawlins Revert "Deprecate --resources-dir option. (`#3696`)" (dart-lang/dartdoc#3782) ecosystem (https://github.com/dart-lang/ecosystem/compare/865b2c5..b2b045f): b2b045f 2024-06-12 Devon Carew remove extraneous quotes (dart-lang/ecosystem#270) fdedf3c 2024-06-11 Devon Carew move to logging; check for safety exceptions (dart-lang/ecosystem#269) 27574e0 2024-06-10 dependabot[bot] Bump the github-actions group with 2 updates (dart-lang/ecosystem#268) 6e53c96 2024-06-10 Devon Carew updates for the blast_repo tool (dart-lang/ecosystem#267) http (https://github.com/dart-lang/http/compare/b522000..e2e2170): e2e2170 2024-06-11 David Wimmer Update README.md (dart-lang/http#1231) f8d5bf8 2024-06-12 Anikate De [pkgs/ok_http] Add functionality to accept and configure redirects. (dart-lang/http#1230) 93ff4a9 2024-06-11 Anikate De [ok_http]: Use the Android SDK to generate JNI bindings. (dart-lang/http#1229) http_parser (https://github.com/dart-lang/http_parser/compare/551e0e4..53d4041): 53d4041 2024-06-10 Kevin Moore blast_repo fixes (dart-archive/http_parser#98) 1ff06e4 2024-06-10 Kevin Moore Update min SDK, test wasm on 3.4 (dart-archive/http_parser#97) path (https://github.com/dart-lang/path/compare/8fc4c72..04807b6): 04807b6 2024-06-10 Kevin Moore Update to latest lints, bump min SDK to 3.4, test wasm on 3.4 (dart-archive/path#168) shelf (https://github.com/dart-lang/shelf/compare/ea3c983..4c54af6): 4c54af6 2024-06-11 Kevin Moore [shelf_test_handler] Bump dev deps (dart-lang/shelf#435) test (https://github.com/dart-lang/test/compare/83c597e..329c6df): 329c6dff 2024-06-10 Jacob MacDonald fix windows failures (dart-lang/test#2244) 777631bb 2024-06-10 Rexios Bump min Dart version to 3.4.0 for WASM (dart-lang/test#2242) webdev (https://github.com/dart-lang/webdev/compare/9ada46f..eccc7d8): eccc7d87 2024-06-12 Parker Lougheed Update `package:lints` and clean up library declarations (dart-lang/webdev#2436) Change-Id: Ic7aede173c9730f0ccd1bc3138f50a92ddf49fce Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371440 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was shocked to find that we had two mechanisms for determining an element's "canonical library":
ModelElement.canonicalLibrary
and aPackageGraph._findCanonicalLibraryFor
. They were not quite the same implementation, but the differences turn out to be uninteresting; the two implementations can be combined. This change removesPackageGraph._findCanonicalLibraryFor
. This implementation was only used in the package graph to find the canonical element for a given element. That code can now just useModelElement.canonicalLibrary
. It requires a fair bit of refactoring all over:PackageGraph.findCanonicalModelElementFor
previously accepted an analyzer Element, instead of a ModelElement, but almost all of the call sites usedfoo.element
or some other expression that could easily be replaced with an access to a ModelElement instead of the correlated Element.ModelElement.definingLibrary
,ModelElement.canonicalLibrary
,ModelElement._searchForCanonicalLibrary
.ContainerMember.computeCanonicalEnclosingContainer
to stop unnecessarily special-casing extensions and extension types.ModelElement._searchForCanonicalLibrary
.ContainerMember.referenceGrandparentOverrides
to not usesync*
.findCanonicalFor
function out ofmodel_utils.dart
and intoinheriting_container.dart
, the only code that uses it anymore.Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.