refactor(dart): Format Dart code

Use the dart formatter to clean up all pure Dart code.

Closes #4832
This commit is contained in:
Tim Blasi
2015-10-20 09:38:14 -07:00
committed by Timothy Blasi
parent 6be95ae88a
commit fd0ba37734
44 changed files with 326 additions and 258 deletions
@@ -24,4 +24,4 @@ class Entity implements Observable {
bool deliverChanges() => null;
notifyPropertyChange(Symbol field, Object oldValue, Object newValue) => null;
void notifyChange(record) {}
}
}
@@ -3,7 +3,7 @@ import "dart:async";
Uri toDartDataUri(String source) {
return Uri.parse("data:application/dart;charset=utf-8,"
"${Uri.encodeComponent(source)}");
"${Uri.encodeComponent(source)}");
}
createIsolateSource(String moduleSource, List<List<String>> moduleImports) {
@@ -24,27 +24,32 @@ main(List args, SendPort replyPort) {
var timeStamp = new DateTime.now().millisecondsSinceEpoch;
dynamic callModule(dynamic data) { return data.map( (a) => a+1); }
dynamic callModule(dynamic data) {
return data.map((a) => a + 1);
}
evalModule(String moduleSource, List<List<String>> imports, List args) {
String source = createIsolateSource(moduleSource, imports);
Completer completer = new Completer();
RawReceivePort receivePort;
receivePort = new RawReceivePort( (message) {
receivePort.close();
completer.complete(message);
});
// Note: we have a special karma plugin that sends files under
// urls like /package_1234 as permanently cached.
// With this, spawning multiple isolates gets faster as Darts does not
// reload the files from the server.
var packageRoot = Uri.parse('/packages_${timeStamp}');
return Isolate.spawnUri(toDartDataUri(source), args, receivePort.sendPort, packageRoot: packageRoot).then( (isolate) {
RawReceivePort errorPort;
errorPort = new RawReceivePort( (message) {
completer.completeError(message);
});
isolate.addErrorListener(errorPort.sendPort);
return completer.future;
String source = createIsolateSource(moduleSource, imports);
Completer completer = new Completer();
RawReceivePort receivePort;
receivePort = new RawReceivePort((message) {
receivePort.close();
completer.complete(message);
});
// Note: we have a special karma plugin that sends files under
// urls like /package_1234 as permanently cached.
// With this, spawning multiple isolates gets faster as Darts does not
// reload the files from the server.
var packageRoot = Uri.parse('/packages_${timeStamp}');
return Isolate
.spawnUri(toDartDataUri(source), args, receivePort.sendPort,
packageRoot: packageRoot)
.then((isolate) {
RawReceivePort errorPort;
errorPort = new RawReceivePort((message) {
completer.completeError(message);
});
isolate.addErrorListener(errorPort.sendPort);
return completer.future;
});
}
@@ -2,7 +2,8 @@ library angular2.test.directives.observable_list_iterable_diff_spec;
import 'package:angular2/testing_internal.dart';
import 'package:observe/observe.dart' show ObservableList;
import 'package:angular2/core.dart' show ObservableListDiffFactory, ChangeDetectorRef;
import 'package:angular2/core.dart'
show ObservableListDiffFactory, ChangeDetectorRef;
@proxy
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {
@@ -7,96 +7,106 @@ import 'package:angular2/src/core/linker/interfaces.dart';
main() {
describe('Create DirectiveMetadata', () {
describe('lifecycle', () {
describe("onChanges", () {
it("should be true when the directive has the onChanges method", () {
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveImplementingOnChanges))
expect(hasLifecycleHook(
LifecycleHooks.OnChanges, DirectiveImplementingOnChanges))
.toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveNoHooks)).toBe(false);
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveNoHooks))
.toBe(false);
});
});
describe("onDestroy", () {
it("should be true when the directive has the onDestroy method", () {
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveImplementingOnDestroy))
expect(hasLifecycleHook(
LifecycleHooks.OnDestroy, DirectiveImplementingOnDestroy))
.toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveNoHooks)).toBe(false);
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveNoHooks))
.toBe(false);
});
});
describe("onInit", () {
it("should be true when the directive has the onInit method", () {
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveImplementingOnInit))
.toBe(true);
expect(hasLifecycleHook(
LifecycleHooks.OnInit, DirectiveImplementingOnInit)).toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveNoHooks)).toBe(false);
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveNoHooks))
.toBe(false);
});
});
describe("doCheck", () {
it("should be true when the directive has the doCheck method", () {
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveImplementingOnCheck))
.toBe(true);
expect(hasLifecycleHook(
LifecycleHooks.DoCheck, DirectiveImplementingOnCheck)).toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveNoHooks)).toBe(false);
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveNoHooks))
.toBe(false);
});
});
describe("afterContentInit", () {
it("should be true when the directive has the afterContentInit method", () {
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit, DirectiveImplementingAfterContentInit))
.toBe(true);
it("should be true when the directive has the afterContentInit method",
() {
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit,
DirectiveImplementingAfterContentInit)).toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit, DirectiveNoHooks))
.toBe(false);
expect(hasLifecycleHook(
LifecycleHooks.AfterContentInit, DirectiveNoHooks)).toBe(false);
});
});
describe("afterContentChecked", () {
it("should be true when the directive has the afterContentChecked method", () {
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked, DirectiveImplementingAfterContentChecked))
.toBe(true);
it("should be true when the directive has the afterContentChecked method",
() {
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked,
DirectiveImplementingAfterContentChecked)).toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked, DirectiveNoHooks))
expect(hasLifecycleHook(
LifecycleHooks.AfterContentChecked, DirectiveNoHooks))
.toBe(false);
});
});
describe("afterViewInit", () {
it("should be true when the directive has the afterViewInit method", () {
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveImplementingAfterViewInit))
.toBe(true);
it("should be true when the directive has the afterViewInit method",
() {
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit,
DirectiveImplementingAfterViewInit)).toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveNoHooks)).toBe(false);
expect(hasLifecycleHook(
LifecycleHooks.AfterViewInit, DirectiveNoHooks)).toBe(false);
});
});
describe("afterViewChecked", () {
it("should be true when the directive has the afterViewChecked method", () {
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked, DirectiveImplementingAfterViewChecked))
.toBe(true);
it("should be true when the directive has the afterViewChecked method",
() {
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked,
DirectiveImplementingAfterViewChecked)).toBe(true);
});
it("should be false otherwise", () {
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked, DirectiveNoHooks))
.toBe(false);
expect(hasLifecycleHook(
LifecycleHooks.AfterViewChecked, DirectiveNoHooks)).toBe(false);
});
});
});
@@ -149,7 +149,8 @@ main() {
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
var cmp = tc.debugElement.componentViewChildren[0].inject(OnChangeComponent);
var cmp = tc.debugElement.componentViewChildren[0]
.inject(OnChangeComponent);
expect(cmp.prop).toEqual('hello');
expect(cmp.changes.containsKey('prop')).toEqual(true);
async.done();
@@ -171,12 +172,14 @@ main() {
directives: [ComponentWithObservableList]))
.createAsync(Dummy)
.then((tc) {
tc.debugElement.componentInstance.value = new ObservableList.from([1, 2]);
tc.debugElement.componentInstance.value =
new ObservableList.from([1, 2]);
tc.detectChanges();
expect(log.result()).toEqual("check");
expect(asNativeElements(tc.debugElement.componentViewChildren)).toHaveText('12');
expect(asNativeElements(tc.debugElement.componentViewChildren))
.toHaveText('12');
tc.detectChanges();
@@ -195,7 +198,8 @@ main() {
.toHaveText('123');
// we replaced the list => a check
tc.debugElement.componentInstance.value = new ObservableList.from([5, 6, 7]);
tc.debugElement.componentInstance.value =
new ObservableList.from([5, 6, 7]);
tc.detectChanges();
@@ -264,9 +268,7 @@ class NoPropertyAccess {
final model = new PropModel();
}
@Component(
selector: 'on-change',
inputs: const ['prop'])
@Component(selector: 'on-change', inputs: const ['prop'])
@View(template: '')
class OnChangeComponent implements OnChanges {
Map changes;
@@ -297,8 +299,7 @@ class ComponentWithObservableList {
Iterable list;
}
@Directive(
selector: 'directive-logging-checks')
@Directive(selector: 'directive-logging-checks')
class DirectiveLoggingChecks implements DoCheck {
Log log;
@@ -31,4 +31,4 @@ PropDecorator propDecorator(value) {
class HasGetterAndSetterDecorators {
@PropDecorator("get") get a {}
@PropDecorator("set") set a(v) {}
}
}
+4 -2
View File
@@ -83,7 +83,8 @@ class SpyProtoViewFactory extends SpyObject implements ProtoViewFactory {
}
@proxy
class SpyProtoElementInjector extends SpyObject implements ProtoElementInjector {
class SpyProtoElementInjector extends SpyObject
implements ProtoElementInjector {
noSuchMethod(m) => super.noSuchMethod(m);
}
@@ -108,7 +109,8 @@ class SpyXHR extends SpyObject implements XHR {
}
@proxy
class SpyRenderEventDispatcher extends SpyObject implements RenderEventDispatcher {
class SpyRenderEventDispatcher extends SpyObject
implements RenderEventDispatcher {
noSuchMethod(m) => super.noSuchMethod(m);
}