style(dart/transform): Change quote character for consistency.

Use ' as a quote character in generated output instead of ".
This commit is contained in:
Tim Blasi 2015-03-12 13:18:36 -07:00
parent 30253592ff
commit 95c9eca64c
15 changed files with 41 additions and 43 deletions

View File

@ -71,7 +71,7 @@ class _ExtractSettersVisitor extends Object
// TODO(kegluneq): Remove this restriction // TODO(kegluneq): Remove this restriction
if (entry.key is SimpleStringLiteral) { if (entry.key is SimpleStringLiteral) {
var propName = entry.key.value; var propName = entry.key.value;
bindPieces.add('"${propName}": (' bindPieces.add('\'${propName}\': ('
'${currentName} o, String value) => o.${propName} = value'); '${currentName} o, String value) => o.${propName} = value');
} else { } else {
logger.error('`bind` currently only supports string literals'); logger.error('`bind` currently only supports string literals');

View File

@ -150,19 +150,19 @@ class CreateNgDepsVisitor extends Object
} }
writer.print('..registerType('); writer.print('..registerType(');
visitNode(node.name); visitNode(node.name);
writer.print(', {"factory": '); writer.print(', {\'factory\': ');
if (ctor == null) { if (ctor == null) {
_generateEmptyFactory(node.name.toString()); _generateEmptyFactory(node.name.toString());
} else { } else {
ctor.accept(_factoryVisitor); ctor.accept(_factoryVisitor);
} }
writer.print(', "parameters": '); writer.print(', \'parameters\': ');
if (ctor == null) { if (ctor == null) {
_generateEmptyParams(); _generateEmptyParams();
} else { } else {
ctor.accept(_paramsVisitor); ctor.accept(_paramsVisitor);
} }
writer.print(', "annotations": '); writer.print(', \'annotations\': ');
node.accept(_metaVisitor); node.accept(_metaVisitor);
writer.print('})'); writer.print('})');

View File

@ -15,7 +15,7 @@ import '../common/read_file.dart';
var formatter = new DartFormatter(); var formatter = new DartFormatter();
void allTests() { void allTests() {
test('should preserve parameter annotations as const instances', () { test('should preserve parameter annotations as const instances.', () {
var inputPath = 'parameter_metadata/soup.dart'; var inputPath = 'parameter_metadata/soup.dart';
var expected = _readFile('parameter_metadata/expected/soup.ngDeps.dart'); var expected = _readFile('parameter_metadata/expected/soup.ngDeps.dart');
var output = var output =

View File

@ -9,9 +9,9 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(SoupComponent, { ..registerType(SoupComponent, {
"factory": 'factory':
(String description, salt) => new SoupComponent(description, salt), (String description, salt) => new SoupComponent(description, salt),
"parameters": const [const [Tasty, String], const [const Inject(Salt)]], 'parameters': const [const [Tasty, String], const [const Inject(Salt)]],
"annotations": const [const Component(selector: '[soup]')] 'annotations': const [const Component(selector: '[soup]')]
}); });
} // {"version":1,"importOffset":104,"registerOffset":451,"imports":["package:angular2/src/core/annotations/annotations.dart"]} } // {"version":1,"importOffset":104,"registerOffset":451,"imports":["package:angular2/src/core/annotations/annotations.dart"]}

View File

@ -9,19 +9,19 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": () => new MyComponent(), 'factory': () => new MyComponent(),
"parameters": const [], 'parameters': const [],
"annotations": const [ 'annotations': const [
const Component(selector: 'soup', services: const [ToolTip]) const Component(selector: 'soup', services: const [ToolTip])
] ]
}) })
..registerType(ToolTip, { ..registerType(ToolTip, {
"factory": () => new ToolTip(), 'factory': () => new ToolTip(),
"parameters": const [], 'parameters': const [],
"annotations": const [ 'annotations': const [
const Decorator( const Decorator(
selector: '[tool-tip]', bind: const {'text': 'tool-tip'}) selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
] ]
}) })
..registerSetters({"text": (ToolTip o, String value) => o.text = value}); ..registerSetters({'text': (ToolTip o, String value) => o.text = value});
} }

View File

@ -3,8 +3,7 @@ library bar;
import 'package:angular2/src/core/annotations/annotations.dart'; import 'package:angular2/src/core/annotations/annotations.dart';
import 'foo.dart' as dep; import 'foo.dart' as dep;
@Component( @Component(selector: '[soup]', services: const [dep.DependencyComponent])
selector: '[soup]', services: const [dep.DependencyComponent])
class MyComponent { class MyComponent {
MyComponent(); MyComponent();
} }

View File

@ -11,12 +11,11 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": () => new MyComponent(), 'factory': () => new MyComponent(),
"parameters": const [], 'parameters': const [],
"annotations": const [ 'annotations': const [
const Component( const Component(
selector: '[soup]', selector: '[soup]', services: const [dep.DependencyComponent])
services: const [dep.DependencyComponent])
] ]
}); });
i0.setupReflection(reflector); i0.setupReflection(reflector);

View File

@ -9,8 +9,8 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(DependencyComponent, { ..registerType(DependencyComponent, {
"factory": () => new DependencyComponent(), 'factory': () => new DependencyComponent(),
"parameters": const [], 'parameters': const [],
"annotations": const [const Component(selector: '[salad]')] 'annotations': const [const Component(selector: '[salad]')]
}); });
} }

View File

@ -3,7 +3,7 @@ library bar;
import 'package:angular2/src/core/annotations/annotations.dart'; import 'package:angular2/src/core/annotations/annotations.dart';
import 'foo.dart'; import 'foo.dart';
@Component(services: const [MyContext]) @Component(componentServices: const [MyContext])
class MyComponent { class MyComponent {
final MyContext c; final MyContext c;
MyComponent(this.c); MyComponent(this.c);

View File

@ -10,10 +10,10 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": (MyContext c) => new MyComponent(c), 'factory': (MyContext c) => new MyComponent(c),
"parameters": const [const [MyContext]], 'parameters': const [const [MyContext]],
"annotations": const [ 'annotations': const [
const Component(services: const [MyContext]) const Component(componentServices: const [MyContext])
] ]
}); });
} }

View File

@ -9,8 +9,8 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": () => new MyComponent(), 'factory': () => new MyComponent(),
"parameters": const [], 'parameters': const [],
"annotations": const [const Component(selector: '[soup]')] 'annotations': const [const Component(selector: '[soup]')]
}); });
} }

View File

@ -9,8 +9,8 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": () => new MyComponent(), 'factory': () => new MyComponent(),
"parameters": const [], 'parameters': const [],
"annotations": const [const Component(selector: '[soup]')] 'annotations': const [const Component(selector: '[soup]')]
}); });
} }

View File

@ -10,9 +10,9 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": () => new MyComponent(), 'factory': () => new MyComponent(),
"parameters": const [], 'parameters': const [],
"annotations": const [ 'annotations': const [
const Component(selector: '[soup]'), const Component(selector: '[soup]'),
const Template(inline: 'Salad') const Template(inline: 'Salad')
] ]

View File

@ -10,10 +10,10 @@ void setupReflection(reflector) {
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, {
"factory": 'factory':
(prefix.MyContext c, String inValue) => new MyComponent(c, inValue), (prefix.MyContext c, String inValue) => new MyComponent(c, inValue),
"parameters": const [const [prefix.MyContext], const [String]], 'parameters': const [const [prefix.MyContext], const [String]],
"annotations": const [ 'annotations': const [
const Component(selector: prefix.preDefinedSelector) const Component(selector: prefix.preDefinedSelector)
] ]
}); });

View File

@ -11,7 +11,7 @@ import '../common/read_file.dart';
void allTests() { void allTests() {
var codegen = new Codegen('web/index.dart', 'web/index.ngDeps.dart'); var codegen = new Codegen('web/index.dart', 'web/index.ngDeps.dart');
test('should remove uses of mirrors & insert calls to generated code', () { test('should remove uses of mirrors & insert calls to generated code.', () {
var code = var code =
readFile('reflection_remover/reflection_remover_files/index.dart'); readFile('reflection_remover/reflection_remover_files/index.dart');
var output = var output =