-
Notifications
You must be signed in to change notification settings - Fork 119
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
Extract Canonicalization from the ModelElement hierarchy #3753
Conversation
abstract mixin class Canonicalization | ||
implements Locatable, Documentable, Warnable { | ||
bool get isCanonical; | ||
final class Canonicalization { |
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.
Oh nice, no more mixin class. Very good. This was super confusing to me.
@@ -59,7 +59,7 @@ import 'package:path/path.dart' as p show Context; | |||
/// helps prevent subtle bugs as generated output for a non-canonical | |||
/// ModelElement will reference itself as part of the "wrong" [Library] from the | |||
/// public interface perspective. | |||
abstract class ModelElement extends Canonicalization | |||
abstract class ModelElement |
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.
This was so weird for me. Glad we're removing this extension.
import 'package:markdown/markdown.dart' as md; | ||
|
||
class Documentation { | ||
final Canonicalization _element; | ||
final Warnable _element; |
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.
(Nothing actionable for this CL, just thoughts)
I think this is better. This reminds me that using the mixin as a type makes code so hard to read. I've come across this Documentation
class so many times and had to figure out what class the Warnable
was and where that class was instantiated.
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.
Yeah I agree. I think maybe using mixins as types is what led to some shoe-horning and complexity.
Revisions updated by `dart tools/rev_sdk_deps.dart`. dartdoc (https://github.com/dart-lang/dartdoc/compare/1ae5b4c..d9e31ff): d9e31ff9 2024-04-22 Sam Rawlins Extract Canonicalization from the ModelElement hierarchy (dart-lang/dartdoc#3753) webdev (https://github.com/dart-lang/webdev/compare/d4f9f67..50bf268): 50bf2687 2024-04-24 Elliott Brooks Add `dwdsLaunch` and `dwdsAttach` events (dart-lang/webdev#2418) 804eb5c5 2024-04-24 Elliott Brooks Reset DWDS and WebDev after release (dart-lang/webdev#2419) 988b03bf 2024-04-23 Elliott Brooks Prepare webdev for release to version 3.5.0 (dart-lang/webdev#2417) 68513c8f 2024-04-23 Elliott Brooks Prepare DWDS for release to version 24.0.0 (dart-lang/webdev#2413) 0b188169 2024-04-22 Elliott Brooks Fix test timeouts related to weak null safety (dart-lang/webdev#2416) Change-Id: Ie366c07cf46d7efb15d67322eac045e6a6bd7fe3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364522 Auto-Submit: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
Canonicalization was one of the mixins in the hierarchy that adds to the tangle; it is sometimes extended, and sometimes mixed in. We'll see below that it added undue API into non-ModelElement classes. I extract it here from the type hierarchy. The class remains, but is now instantiated by ModelElement when necessary.
This is mostly a no-op, but there are a few changes that could conceivably lead to different behavior, although I personally cannot conceive of how 😄
calculateCanonicalCandidate
, do not split a package name at all (used to be split withlocationSplitter
). I don't think the package names have ever been split.calculateCanonicalCandidate
, only split a library name by '.' characters (used to be split withlocationSplitter
). I don't think libraries can contain the other characters.The refactoring leads to a number of other improvements:
Canonicalization.isCanonical
to Locatable. All Canonicalization-subtyping classes also subtype this mixin.Canonicalization.locationPieces
and all implementations. ModelElement.locationPieces can be inlined, and the other implementations were unnecessary; only required to satisfy the contract.Nameable.namePart
field.locationSplitter
top-level variable tocanonicalization.dart
, now the only place where it is referenced.Documentation._element
a Warnable, instead of a Canonicalization.These hierarchies can probably be simplified further. In particular, I think Locatable and Warnable can be combined. I'd like to explore that later.
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.