Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Issue 927373004: Initial commit of Dart transformer to generate constructor stubs, see https://github.com/angular/an… (Closed)

Created:
5 years, 10 months ago by tjblasi
Modified:
5 years, 8 months ago
Reviewers:
jakemac
Base URL:
https://github.com/kegluneq/angular.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Initial commit of Dart transformer to generate constructor stubs, see https://github.com/angular/angular/issues/496. Add some basic code for generating the "annotations" property. See https://github.com/angular/angular/issues/498. BUG=

Patch Set 1 #

Total comments: 35

Patch Set 2 : Fixing review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -42 lines) Patch
M modules/angular2/src/transform/annotation_processor.dart View 1 4 chunks +5 lines, -3 lines 0 comments Download
M modules/angular2/src/transform/codegen.dart View 1 7 chunks +20 lines, -27 lines 0 comments Download
M modules/angular2/src/transform/html_transform.dart View 1 1 chunk +1 line, -1 line 0 comments Download
M modules/angular2/src/transform/options.dart View 1 1 chunk +1 line, -1 line 0 comments Download
M modules/angular2/src/transform/resolvers.dart View 1 1 chunk +2 lines, -0 lines 0 comments Download
M modules/angular2/src/transform/transformer.dart View 1 3 chunks +8 lines, -8 lines 0 comments Download
M modules/angular2/src/transform/traversal.dart View 1 1 chunk +2 lines, -0 lines 0 comments Download
M modules/angular2/test/transform/common.dart View 1 1 chunk +1 line, -1 line 0 comments Download
M modules/angular2/test/transform/transform_test.dart View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 5 (1 generated)
tjblasi
I have a big favor to ask - would you mind reviewing this code? Since ...
5 years, 10 months ago (2015-02-17 21:19:27 UTC) #2
jakemac
just did a quick pass, I can come back and do a more in depth ...
5 years, 10 months ago (2015-02-17 23:46:46 UTC) #3
jakemac
Ok had another fresh look this morning, everything mostly looks good. When you get in ...
5 years, 10 months ago (2015-02-18 16:18:50 UTC) #4
tjblasi
5 years, 10 months ago (2015-02-18 21:18:26 UTC) #5
Thanks for the review -- no need to re-review if you don't want to, just wanted
to get some additional eyes on the code.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
File modules/angular2/src/transform/annotation_processor.dart (right):

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/annotation_processor.dart:1: import
'dart:collection' show Queue;
On 2015/02/17 23:46:45, jakemac wrote:
> Should probably add a library/license (ditto other files)

None of the other files seem to have licenses right now, so I'll leave it off
for the time being.

Added libraries.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/annotation_processor.dart:8: final initQueue =
new Queue<AnnotationMatch>();
On 2015/02/17 23:46:45, jakemac wrote:
> nit: may want to rename this

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/annotation_processor.dart:19: /// 2) ([element],
[_annotationClass]) has been seen previously.
On 2015/02/17 23:46:45, jakemac wrote:
> has -> has not?

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
File modules/angular2/src/transform/codegen.dart (right):

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:19: DirectiveRegistry
_directiveRegistry;
On 2015/02/18 16:18:50, jakemac wrote:
> might be nice to have a comment here

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:29: if (_logger != null) {
On 2015/02/17 23:46:45, jakemac wrote:
> nit, you could rewrite this:
> 
> if (_logger == null) throw new Error(errorString);
> _logger.error(errorString);

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:41: var prefix = lib != null &&
!lib.isInSdk
On 2015/02/18 16:18:50, jakemac wrote:
> I might reorganize this a little bit to return early for the null case:
> 
> if (lib == null || lib.isInSdk) return '';
> return _libraryPrefixes.putIfAbsent(
>     lib, () => '$i{_libraryPrefixes.length}');

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:48: abstract class DirectiveRegistry
{
On 2015/02/18 16:18:50, jakemac wrote:
> A comment here would be good

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:53: const _reflectorImport =
On 2015/02/18 16:18:50, jakemac wrote:
> You might just want to use ''' here

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:130: if (element.node is!
ClassDeclaration) {
On 2015/02/17 23:46:46, jakemac wrote:
> Just fyi, any call to `.node` is potentially pretty expensive. You probably
want
> to store these in a variable that gets cached. I recenty did this do the
> InitializerData class in the initialize transformer,
> https://github.com/dart-lang/initialize/blob/master/lib/transformer.dart#L461.
I
> don't have a good idea of exactly how much of an issue this is, so I will
leave
> it up to your best judgment as to whether its worth updating now, but I would
at
> least put in a TODO.

Added an issue [https://github.com/kegluneq/angular/issues/4] & TODO.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:201: /// @param node the node to be
visited
On 2015/02/17 23:46:45, jakemac wrote:
> I haven't really seen us use these JavaDoc style comments, does the doc
> generator support them?

Ah, I stole this code from analyzer, which was generated from Java code. Fixed.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/codegen.dart:208: /**
On 2015/02/17 23:46:46, jakemac wrote:
> Usually we just do the /// style comments, not sure if this is against style
> guides or not.

Done.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
File modules/angular2/src/transform/html_transform.dart (right):

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/html_transform.dart:15: // TODO(jakemac): support
package urls with [options.entryPoint] or
On 2015/02/18 16:18:50, jakemac wrote:
> The initialize package now handles this, up to you if you want to copy the
logic
> over. Basically it just accepts an `entry_point` now and based on the file
> extension (.dart or .html) it does the right thing.

Acknowledged.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
File modules/angular2/src/transform/transformer.dart (right):

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/transformer.dart:27: static const
_entryPointParam = 'entry_point';
On 2015/02/17 23:46:46, jakemac wrote:
> not sure that these are necessary, they only appear once below

They're probably going to change in the future -- this helps me keep them
straight.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
File modules/angular2/src/transform/traversal.dart (right):

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/traversal.dart:6: class ImportTraversal {
On 2015/02/17 23:46:46, jakemac wrote:
> ImportTraverser maybe?

Acknowledged.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/traversal.dart:13: void traverse(LibraryElement
library, [Set<LibraryElement> seen]) {
On 2015/02/18 16:18:50, jakemac wrote:
> Looks to me like this is still doing the normal traversal that `initialize`
> does. Did the design change on that for angular? If so we could get rid of a
ton
> of this code potentially by converting it to an InitializerPlugin.

Discussed offline

https://codereview.chromium.org/927373004/diff/1/modules/angular2/src/transfo...
modules/angular2/src/transform/traversal.dart:28: if
(_annotationMatcher.processAnnotations(superClass.element) &&
On 2015/02/17 23:46:46, jakemac wrote:
> I think that for angular this might not matter, as long as super classes don't
> have to be registered before child classes.

Acknowledged.

https://codereview.chromium.org/927373004/diff/1/modules/angular2/test/transf...
File modules/angular2/test/transform/transform_test.dart (right):

https://codereview.chromium.org/927373004/diff/1/modules/angular2/test/transf...
modules/angular2/test/transform/transform_test.dart:25: class TestConfig {
On 2015/02/18 16:18:50, jakemac wrote:
> Personally I kind of like just inlining these files, and it makes the tests
run
> faster. I don't feel that strongly though.

I'm pretty ambivalent, but Misko strongly preferred having them separated out.

Powered by Google App Engine
This is Rietveld 408576698