Skip to content

Type helper cleanup, library reorganizations #21

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

Merged
merged 6 commits into from
Jul 24, 2017
Merged

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Jul 21, 2017

Reorganize libraries so there is one clear import for each use case.
Support nesting in TypeHelper.
Cleanup the API for TypeHelper
Other misc

@kevmoo kevmoo force-pushed the type_helper_more branch 3 times, most recently from 324ec97 to 8818d8f Compare July 22, 2017 20:40
@kevmoo kevmoo changed the title WIP: Type helper cleanup Type helper cleanup Jul 23, 2017
@kevmoo kevmoo changed the title Type helper cleanup Type helper cleanup, library reorganizations Jul 23, 2017
@kevmoo kevmoo requested a review from natebosch July 23, 2017 00:29
@kevmoo
Copy link
Collaborator Author

kevmoo commented Jul 23, 2017

@natebosch it's big, but it's really nice

CC @jakemac53

@kevmoo kevmoo mentioned this pull request Jul 23, 2017
kevmoo added 4 commits July 23, 2017 13:06
You can reuse the same name – `e` in our case – at each level
It makes reading the generated code a bit harder – so use tools
@kevmoo kevmoo force-pushed the type_helper_more branch from 68b250a to fe93e28 Compare July 23, 2017 20:08
@kevmoo
Copy link
Collaborator Author

kevmoo commented Jul 23, 2017

@natebosch – rebased on latest

Copy link
Member

@natebosch natebosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would definitely be easier to review in smaller increments... but overall looks good.

@@ -1,7 +1,27 @@
## 0.2.0

* **BREAKING** Types are now segmented into their own libraries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] why the blank lines? (just realized they've been in there from the start...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit easier to read the source and the parsed markdown.

import 'utils.dart';

final _substitute = "e";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] maybe a comment or a more descriptive variable name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

static const _defaultHelpers = const [
const JsonHelper(),
const DateTimeHelper()
const DateTimeHelper(),
const CoreHelper()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feel odd that there is both a _coreHelpers and a CoreHelper()...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also caught a bug! – CoreHelper should be in _coreHelpers!

valueType.isObject ||
_stringBoolNumChecker.isAssignableFromType(valueType);
String _serialize(DartType targetType, String expression) => _allHelpers
.map((th) => th.serialize(targetType, expression, _serialize))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

th?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeHelper – would you prefer e?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just h for 'helper' coming from _allHelpers -> or change it to _allTypeHelpers and keep th

/// returns the generic arguments to the [checker] [Type] if there are any.
///
/// If the [checker] [Type] doesn't have generic arguments, `null` is returned.
List<DartType> getTypeArguments(DartType type, TypeChecker checker) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] could be typeArguments or typeArgumentsOf... get doesn't add value most of the time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

// the time.
@override
bool canSerialize(DartType type) => canDeserialize(type);
/// A [TypeChecker] for [String].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Is the comment adding new information?

BTW a pattern I've seen Matan use with TypeChecker is to name the variable like $String which makes the usage look nicer than repeating TypeChecker

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh...I think this is deleted code...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. Found it. Uh...it makes it clear what it's for.

Better a trivial doc comment than no doc comment. This is a public API.

Not sure where you're going with the $String thing...

@kevmoo kevmoo force-pushed the type_helper_more branch 2 times, most recently from 69d86d8 to 2eb9284 Compare July 24, 2017 16:47
Allows `Iterable`, `List`, and `Map` to be implemented as helpers
Allow rename and reorganize public libraries.
@kevmoo kevmoo force-pushed the type_helper_more branch from 2eb9284 to 8fe4786 Compare July 24, 2017 16:55
@kevmoo kevmoo merged commit 8fe4786 into master Jul 24, 2017
@kevmoo kevmoo deleted the type_helper_more branch July 24, 2017 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants