diff --git a/modules/angular2/src/transform/codegen.dart b/modules/angular2/src/transform/codegen.dart index 1fcbd8f754..74e9ac233b 100644 --- a/modules/angular2/src/transform/codegen.dart +++ b/modules/angular2/src/transform/codegen.dart @@ -224,6 +224,14 @@ abstract class _TransformVisitor extends ToSourceVisitor { } } + @override + Object visitPrefixedIdentifier(PrefixedIdentifier node) { + // We add our own prefixes in [visitSimpleIdentifier], discard any used in + // the original source. + _visitNode(node.identifier); + return null; + } + @override Object visitSimpleIdentifier(SimpleIdentifier node) { // Make sure the identifier is prefixed if necessary. @@ -281,6 +289,7 @@ class _CtorTransformVisitor extends _TransformVisitor { @override Object visitDefaultFormalParameter(DefaultFormalParameter node) { _visitNode(node.parameter); + // Ignore the declared default value. return null; } diff --git a/modules/angular2/test/transform/common.dart b/modules/angular2/test/transform/common.dart deleted file mode 100644 index f6a8e7de90..0000000000 --- a/modules/angular2/test/transform/common.dart +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -library angular2.test.transform; - -// TODO(kegluneq): Remove this and use the actual Directive def'n. -// Simple mock of Directive. -class Directive { - final context; - const Directive({this.context}); -} diff --git a/modules/angular2/test/transform/ctor_with_default_value_files/bar.dart b/modules/angular2/test/transform/ctor_with_default_value_files/bar.dart deleted file mode 100644 index 148a76db00..0000000000 --- a/modules/angular2/test/transform/ctor_with_default_value_files/bar.dart +++ /dev/null @@ -1,9 +0,0 @@ -library bar; - -import 'package:angular2/src/core/annotations/annotations.dart'; - -@Directive(context: 'soup') -class Component { - final dynamic c; - Component([this.c = 'sandwich']); -} diff --git a/modules/angular2/test/transform/ctor_with_default_value_files/expected/index.bootstrap.dart b/modules/angular2/test/transform/ctor_with_default_value_files/expected/index.bootstrap.dart deleted file mode 100644 index 8351124b03..0000000000 --- a/modules/angular2/test/transform/ctor_with_default_value_files/expected/index.bootstrap.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:angular2/src/reflection/reflection.dart' show reflector; -import 'bar.dart' as i0; -import 'package:angular2/src/core/annotations/annotations.dart' as i1; -import 'index.dart' as i2; - -main() { - reflector - ..registerType(i0.Component, { - "factory": (dynamic c) => new i0.Component(c), - "parameters": const [const [dynamic]], - "annotations": const [const i1.Directive(context: 'soup')] - }); - i2.main(); -} diff --git a/modules/angular2/test/transform/ctor_with_default_value_files/index.dart b/modules/angular2/test/transform/ctor_with_default_value_files/index.dart deleted file mode 100644 index f65483f03e..0000000000 --- a/modules/angular2/test/transform/ctor_with_default_value_files/index.dart +++ /dev/null @@ -1,7 +0,0 @@ -library web_foo; - -import 'bar.dart'; - -void main() { - new Component('Things'); -} diff --git a/modules/angular2/test/transform/list_of_types_files/bar.dart b/modules/angular2/test/transform/list_of_types_files/bar.dart index a650901dab..2d242c1396 100644 --- a/modules/angular2/test/transform/list_of_types_files/bar.dart +++ b/modules/angular2/test/transform/list_of_types_files/bar.dart @@ -3,8 +3,8 @@ library bar; import 'package:angular2/src/core/annotations/annotations.dart'; import 'foo.dart'; -@Directive(context: const [MyContext]) -class Component { +@Component(componentServices: const [MyContext]) +class MyComponent { final MyContext c; - Component(this.c); + MyComponent(this.c); } diff --git a/modules/angular2/test/transform/list_of_types_files/expected/index.bootstrap.dart b/modules/angular2/test/transform/list_of_types_files/expected/index.bootstrap.dart index df78c957ab..af522abf4f 100644 --- a/modules/angular2/test/transform/list_of_types_files/expected/index.bootstrap.dart +++ b/modules/angular2/test/transform/list_of_types_files/expected/index.bootstrap.dart @@ -6,10 +6,12 @@ import 'index.dart' as i3; main() { reflector - ..registerType(i0.Component, { - "factory": (i1.MyContext c) => new i0.Component(c), + ..registerType(i0.MyComponent, { + "factory": (i1.MyContext c) => new i0.MyComponent(c), "parameters": const [const [i1.MyContext]], - "annotations": const [const i2.Directive(context: const [i1.MyContext])] + "annotations": const [ + const i2.Component(componentServices: const [i1.MyContext]) + ] }); i3.main(); } diff --git a/modules/angular2/test/transform/simple_annotation_files/bar.dart b/modules/angular2/test/transform/simple_annotation_files/bar.dart index bc846728d1..667a41a50a 100644 --- a/modules/angular2/test/transform/simple_annotation_files/bar.dart +++ b/modules/angular2/test/transform/simple_annotation_files/bar.dart @@ -2,7 +2,7 @@ library bar; import 'package:angular2/src/core/annotations/annotations.dart'; -@Directive(context: 'soup') -class Component { - Component(); +@Component(selector: '[soup]') +class MyComponent { + MyComponent(); } diff --git a/modules/angular2/test/transform/simple_annotation_files/expected/index.bootstrap.dart b/modules/angular2/test/transform/simple_annotation_files/expected/index.bootstrap.dart index 0d84b803bd..ddd73afec5 100644 --- a/modules/angular2/test/transform/simple_annotation_files/expected/index.bootstrap.dart +++ b/modules/angular2/test/transform/simple_annotation_files/expected/index.bootstrap.dart @@ -5,10 +5,10 @@ import 'index.dart' as i2; main() { reflector - ..registerType(i0.Component, { - "factory": () => new i0.Component(), + ..registerType(i0.MyComponent, { + "factory": () => new i0.MyComponent(), "parameters": const [const []], - "annotations": const [const i1.Directive(context: 'soup')] + "annotations": const [const i1.Component(selector: '[soup]')] }); i2.main(); } diff --git a/modules/angular2/test/transform/simple_annotation_files/index.dart b/modules/angular2/test/transform/simple_annotation_files/index.dart index f65483f03e..ca52b6d537 100644 --- a/modules/angular2/test/transform/simple_annotation_files/index.dart +++ b/modules/angular2/test/transform/simple_annotation_files/index.dart @@ -3,5 +3,5 @@ library web_foo; import 'bar.dart'; void main() { - new Component('Things'); + new MyComponent('Things'); } diff --git a/modules/angular2/test/transform/synthetic_ctor_files/bar.dart b/modules/angular2/test/transform/synthetic_ctor_files/bar.dart index 9ebd816d75..bb515e525a 100644 --- a/modules/angular2/test/transform/synthetic_ctor_files/bar.dart +++ b/modules/angular2/test/transform/synthetic_ctor_files/bar.dart @@ -2,5 +2,5 @@ library bar; import 'package:angular2/src/core/annotations/annotations.dart'; -@Directive(context: 'soup') -class Component {} +@Component(selector: '[soup]') +class MyComponent {} diff --git a/modules/angular2/test/transform/synthetic_ctor_files/expected/index.bootstrap.dart b/modules/angular2/test/transform/synthetic_ctor_files/expected/index.bootstrap.dart index 0d84b803bd..ddd73afec5 100644 --- a/modules/angular2/test/transform/synthetic_ctor_files/expected/index.bootstrap.dart +++ b/modules/angular2/test/transform/synthetic_ctor_files/expected/index.bootstrap.dart @@ -5,10 +5,10 @@ import 'index.dart' as i2; main() { reflector - ..registerType(i0.Component, { - "factory": () => new i0.Component(), + ..registerType(i0.MyComponent, { + "factory": () => new i0.MyComponent(), "parameters": const [const []], - "annotations": const [const i1.Directive(context: 'soup')] + "annotations": const [const i1.Component(selector: '[soup]')] }); i2.main(); } diff --git a/modules/angular2/test/transform/synthetic_ctor_files/index.dart b/modules/angular2/test/transform/synthetic_ctor_files/index.dart index 2fa127c5d5..73b7d455d0 100644 --- a/modules/angular2/test/transform/synthetic_ctor_files/index.dart +++ b/modules/angular2/test/transform/synthetic_ctor_files/index.dart @@ -3,5 +3,5 @@ library web_foo; import 'bar.dart'; void main() { - new Component(); + new MyComponent(); } diff --git a/modules/angular2/test/transform/transform_test.dart b/modules/angular2/test/transform/transform_test.dart index 9725606180..32c3988212 100644 --- a/modules/angular2/test/transform/transform_test.dart +++ b/modules/angular2/test/transform/transform_test.dart @@ -1,4 +1,4 @@ -library angular2.test.transform; +library angular2.test; import 'dart:io'; import 'package:barback/barback.dart'; @@ -8,8 +8,6 @@ import 'package:dart_style/dart_style.dart'; import 'package:unittest/unittest.dart'; import 'package:unittest/vm_config.dart'; -import 'common.dart'; - main() { useVMConfiguration(); @@ -41,7 +39,8 @@ void _runTests() { inputs: { 'a|web/index.html': 'common.html', 'a|web/index.dart': 'html_entry_point_files/index.dart', - 'angular2|lib/src/core/annotations/annotations.dart': 'common.dart' + 'angular2|lib/src/core/annotations/annotations.dart': + '../../lib/src/core/annotations/annotations.dart' }, outputs: { 'a|web/index.html': 'html_entry_point_files/expected/index.html' @@ -51,7 +50,8 @@ void _runTests() { 'a|web/index.html': 'common.html', 'a|web/index.dart': 'simple_annotation_files/index.dart', 'a|web/bar.dart': 'simple_annotation_files/bar.dart', - 'angular2|lib/src/core/annotations/annotations.dart': 'common.dart' + 'angular2|lib/src/core/annotations/annotations.dart': + '../../lib/src/core/annotations/annotations.dart' }, outputs: { 'a|web/index.bootstrap.dart': @@ -63,7 +63,8 @@ void _runTests() { 'a|web/index.dart': 'two_deps_files/index.dart', 'a|web/foo.dart': 'two_deps_files/foo.dart', 'a|web/bar.dart': 'two_deps_files/bar.dart', - 'angular2|lib/src/core/annotations/annotations.dart': 'common.dart' + 'angular2|lib/src/core/annotations/annotations.dart': + '../../lib/src/core/annotations/annotations.dart' }, outputs: { 'a|web/index.bootstrap.dart': @@ -75,29 +76,20 @@ void _runTests() { 'a|web/index.dart': 'list_of_types_files/index.dart', 'a|web/foo.dart': 'list_of_types_files/foo.dart', 'a|web/bar.dart': 'list_of_types_files/bar.dart', - 'angular2|lib/src/core/annotations/annotations.dart': 'common.dart' + 'angular2|lib/src/core/annotations/annotations.dart': + '../../lib/src/core/annotations/annotations.dart' }, outputs: { 'a|web/index.bootstrap.dart': 'list_of_types_files/expected/index.bootstrap.dart' }), - new TestConfig('Component ctor with default value', - inputs: { - 'a|web/index.html': 'common.html', - 'a|web/index.dart': 'ctor_with_default_value_files/index.dart', - 'a|web/bar.dart': 'ctor_with_default_value_files/bar.dart', - 'angular2|lib/src/core/annotations/annotations.dart': 'common.dart' - }, - outputs: { - 'a|web/index.bootstrap.dart': - 'ctor_with_default_value_files/expected/index.bootstrap.dart' - }), new TestConfig('Component with synthetic Constructor', inputs: { 'a|web/index.html': 'common.html', 'a|web/index.dart': 'synthetic_ctor_files/index.dart', 'a|web/bar.dart': 'synthetic_ctor_files/bar.dart', - 'angular2|lib/src/core/annotations/annotations.dart': 'common.dart' + 'angular2|lib/src/core/annotations/annotations.dart': + '../../lib/src/core/annotations/annotations.dart' }, outputs: { 'a|web/index.bootstrap.dart': diff --git a/modules/angular2/test/transform/two_deps_files/bar.dart b/modules/angular2/test/transform/two_deps_files/bar.dart index 1604b388a0..1bb0b1116e 100644 --- a/modules/angular2/test/transform/two_deps_files/bar.dart +++ b/modules/angular2/test/transform/two_deps_files/bar.dart @@ -1,13 +1,13 @@ library bar; import 'package:angular2/src/core/annotations/annotations.dart'; -import 'foo.dart'; +import 'foo.dart' as prefix; -@Directive(context: const MyContext(contextString)) -class Component2 { - final MyContext c; +@Component(selector: prefix.preDefinedSelector) +class MyComponent { + final prefix.MyContext c; final String generatedValue; - Component2(this.c, String inValue) { + MyComponent(this.c, String inValue) { generatedValue = 'generated ' + inValue; } } diff --git a/modules/angular2/test/transform/two_deps_files/expected/index.bootstrap.dart b/modules/angular2/test/transform/two_deps_files/expected/index.bootstrap.dart index 8e38a7a82a..5676e38ced 100644 --- a/modules/angular2/test/transform/two_deps_files/expected/index.bootstrap.dart +++ b/modules/angular2/test/transform/two_deps_files/expected/index.bootstrap.dart @@ -6,12 +6,12 @@ import 'index.dart' as i3; main() { reflector - ..registerType(i0.Component2, { + ..registerType(i0.MyComponent, { "factory": - (i1.MyContext c, String inValue) => new i0.Component2(c, inValue), + (i1.MyContext c, String inValue) => new i0.MyComponent(c, inValue), "parameters": const [const [i1.MyContext, String]], "annotations": const [ - const i2.Directive(context: const i1.MyContext(i1.contextString)) + const i2.Component(selector: i1.preDefinedSelector) ] }); i3.main(); diff --git a/modules/angular2/test/transform/two_deps_files/foo.dart b/modules/angular2/test/transform/two_deps_files/foo.dart index 3a081616fb..444220e3d4 100644 --- a/modules/angular2/test/transform/two_deps_files/foo.dart +++ b/modules/angular2/test/transform/two_deps_files/foo.dart @@ -1,8 +1,8 @@ library foo; -const contextString = 'soup'; +const preDefinedSelector = 'soup'; class MyContext { - final String s; - const MyContext(this.s); + final String selector; + const MyContext(this.selector); } diff --git a/modules/angular2/test/transform/two_deps_files/index.dart b/modules/angular2/test/transform/two_deps_files/index.dart index f65483f03e..ca52b6d537 100644 --- a/modules/angular2/test/transform/two_deps_files/index.dart +++ b/modules/angular2/test/transform/two_deps_files/index.dart @@ -3,5 +3,5 @@ library web_foo; import 'bar.dart'; void main() { - new Component('Things'); + new MyComponent('Things'); }