-
Notifications
You must be signed in to change notification settings - Fork 412
Refactor for reuse #122
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
Refactor for reuse #122
Conversation
@@ -0,0 +1,6 @@ | |||
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
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.
2018
json_serializable/lib/src/utils.dart
Outdated
|
||
final _dartCoreObjectChecker = const TypeChecker.fromRuntime(Object); | ||
|
||
/// Returns the set of fields that are written to via factory. |
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.
blank line after the first sentence
I'm assuming there are side effects to this method (like writing to buffer
) - maybe we should focus on those in the first description rather than the return value?
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.
Did a big clean-up here
json_serializable/lib/src/utils.dart
Outdated
{ParameterElement ctorParam})) { | ||
var fieldsSetByFactory = new Set<FieldElement>(); | ||
var className = classElement.displayName; | ||
// Create the factory method |
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.
what is this meant to be describing?
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.
Removed – old noise.
json_serializable/lib/src/utils.dart
Outdated
var className = classElement.displayName; | ||
// Create the factory method | ||
|
||
// Get the default constructor |
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 is a "what" comment - is there a "why" we should be documenting? Or should we drop the comment? Or pull it out into a method named findDefaultConstructor(...)
?
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.
Removed and adding a TODO around #50
json_serializable/lib/src/utils.dart
Outdated
.difference(fieldsSetByFactory); | ||
|
||
// | ||
// Generate the static factory method |
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 method is ~100 lines and big section comments like this make me think it could be broken up into different methods.
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 did a bit of cleanup. There is a lot of state in a few var
s here. I'd have to create another class to ship them between functions, which seems like more noise than it's worth
@natebosch – fixed copyright year... |
The only user-visible change here is fixing some error messages.
Otherwise, this just makes a few members public in a way that allows experimenting with reuse from other code.
Eventually, the code may end up in
source_gen
– but we'll take our time.