-
Notifications
You must be signed in to change notification settings - Fork 124
Prevent private or non-canonical elements from ever generating links #1589
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
Conversation
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.
DBQ: no tests?
test added. |
gracias |
@@ -654,8 +661,11 @@ class Class extends ModelElement | |||
|
|||
@override | |||
String get href { | |||
if (canonicalLibrary == null) return null; | |||
return '${canonicalLibrary.dirName}/$fileName'; | |||
if (!identical(canonicalModelElement, this)) |
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.
nit: braces for the if statement body
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.
Just for clarity, if this element is not the canonical one, we generate a link to the canonical one?
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.
Correct. While you could infer that from the code previously with all the "canonicalEnclosingElement" stuff, the modification here is intended to make that more clear and to make the object being linked to actually responsible for its own link generation.
Most of the broken link bugs I've seen either were attributable to bugs in how this worked, or were made harder to fix because of it (like this one). Now elements no longer point blindly into the filesystem hoping that the model really has a canonical element that matches, but we actually look up the 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.
I've got a second change on deck to eliminate the copypasta of hrefs everywhere; if possible I'd prefer to fix the braces there.
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.
sgtm
if (canonicalLibrary == null) return null; | ||
return '${canonicalLibrary.dirName}/${_constructor.enclosingElement.name}/$name.html'; | ||
if (!identical(canonicalModelElement, this)) | ||
return canonicalModelElement?.href; |
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.
here as well, and below
@@ -1920,6 +1922,10 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, | |||
expect(aStaticConstField.constantValue, '"A Constant Dog"'); | |||
}); | |||
|
|||
test('privately constructed constants are unlinked', () { |
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.
👍
Fixes #1588. First part of a long awaited refactor to rationalize how we calculate links, but moved up to fix a regression.