-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Change all ocurrences of '$runtimeType#$hashCode' to use the idAndType method. #10871
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
…e method. The idAndType method generates a shorter description with a consistent length consisting of the runtime type and the a 5 hex character long truncated version of the hash code.
| } | ||
| } | ||
| } | ||
|
|
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.
let's put this in a different file, maybe the tree 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.
done
| return object.hashCode.toUnsigned(20).toRadixString(16).padLeft(5, '0'); | ||
| } | ||
|
|
||
| /// Returns a summary of [object]'s runtime type and hash code. |
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.
For arguments we use backticks rather than square brackets because they don't actually hyperlink.
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.
(it also causes weird results for methods if you override the method but change the argument name)
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.
done
| } | ||
|
|
||
| /// Returns a summary of [object]'s runtime type and hash code. | ||
| String idAndType(Object object) => '${object.runtimeType}#${shortHash(object)}'; |
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.
describeIdentity ?
| } | ||
| } | ||
|
|
||
| /// Returns a 5 character long hexadecimal hash code for [object]. |
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.
Can you elaborate on these docs, for example saying that it uses Object.hashCode's twenty least-significant bits?
Also maybe rather than saying it returns a hash code, say that it returns a string based on the hash code? Hash codes are integers and this returns a string. Feel free to phrase this however you want.
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.
Done.
|
Please make sure you wait for all the checks to pass before landing, even if you only changed comments. We have tests that verify the bodies of comments. |
…idAndType method. (flutter#10871)" This reverts commit d46e208.
|
My fault. Reverted for now. I'll re-land in the morning with the case the IntelliJ refactor tool was missing. Odd IntelliJ was showing 0 analyzer issues. |
|
Oh wow, I didn't even notice it had actually caused a problem! Just goes to show, I guess! |
…use the idAndType method. (flutter#10871)" (flutter#10880)" This reverts commit ceb814a.
…e method. (flutter#10871) * Change all instances of '$runtimeType#$hashCode' to use the describeIdentity method. The describeIdentity method generates a shorter description with a consistent length consisting of the runtime type and the a 5 hex character long truncated version of the hash code.
…idAndType method. (flutter#10871)" (flutter#10880) This reverts commit d46e208.
…eIdentity (flutter#10888) * Revert "Revert "Change all ocurrences of '$runtimeType#$hashCode' to use the idAndType method. (flutter#10871)" (flutter#10880)" This reverts commit ceb814a.
The idAndType method generates a shorter description with a consistent length
consisting of the runtime type and the a 5 hex character long truncated
version of the hash code.
Feel free to suggest a different method name. I'm not happy about idAndType but I couldn't thinking of anything better and figured you would probably have an opinion on what name would fit well with the rest of Flutter.