style(dart): Run dartfmt v0.1.8+2 on all pure Dart code

Update formatting for all pure Dart code in the repo.
This commit is contained in:
Tim Blasi
2015-07-27 17:26:28 -07:00
parent 6fac901151
commit 2c9951273a
63 changed files with 406 additions and 273 deletions

View File

@ -15,8 +15,7 @@ export 'package:angular2/src/change_detection/directive_record.dart'
show DirectiveIndex, DirectiveRecord;
export 'package:angular2/src/change_detection/interfaces.dart'
show ChangeDetector, ChangeDetectorDefinition, ProtoChangeDetector;
export 'package:angular2/src/change_detection/pipes/pipes.dart'
show Pipes;
export 'package:angular2/src/change_detection/pipes/pipes.dart' show Pipes;
export 'package:angular2/src/change_detection/proto_record.dart'
show ProtoRecord;
export 'package:angular2/src/change_detection/change_detection_util.dart'
@ -27,8 +26,7 @@ typedef ProtoChangeDetector PregenProtoChangeDetectorFactory(
ChangeDetectorDefinition definition);
typedef ChangeDetector InstantiateMethod(dynamic dispatcher,
List<ProtoRecord> protoRecords,
List<DirectiveRecord> directiveRecords);
List<ProtoRecord> protoRecords, List<DirectiveRecord> directiveRecords);
/// Implementation of [ProtoChangeDetector] for use by pre-generated change
/// detectors in Angular 2 Dart.
@ -52,19 +50,19 @@ class PregenProtoChangeDetector extends ProtoChangeDetector {
static bool isSupported() => true;
factory PregenProtoChangeDetector(InstantiateMethod instantiateMethod,
ChangeDetectorDefinition def) {
factory PregenProtoChangeDetector(
InstantiateMethod instantiateMethod, ChangeDetectorDefinition def) {
// TODO(kegluneq): Pre-generate these (#2067).
var recordBuilder = new ProtoRecordBuilder();
def.bindingRecords.forEach((b) {
recordBuilder.add(b, def.variableNames);
});
var protoRecords = coalesce(recordBuilder.records);
return new PregenProtoChangeDetector._(def.id, instantiateMethod,
protoRecords, def.directiveRecords);
return new PregenProtoChangeDetector._(
def.id, instantiateMethod, protoRecords, def.directiveRecords);
}
@override
instantiate(dynamic dispatcher) => _instantiateMethod(
dispatcher, _protoRecords, _directiveRecords);
instantiate(dynamic dispatcher) =>
_instantiateMethod(dispatcher, _protoRecords, _directiveRecords);
}

View File

@ -3,7 +3,8 @@ library angular2.application;
import 'dart:async';
import 'package:angular2/src/reflection/reflection.dart' show reflector;
import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities;
import 'package:angular2/src/reflection/reflection_capabilities.dart'
show ReflectionCapabilities;
import 'application_common.dart';
export 'application_common.dart' show ApplicationRef;

View File

@ -6,8 +6,7 @@ import 'application_common.dart';
/// Starts an application from a root component.
///
/// See [commonBootstrap] for detailed documentation.
Future<ApplicationRef> bootstrapStatic(
Type appComponentType,
Future<ApplicationRef> bootstrapStatic(Type appComponentType,
[List componentInjectableBindings]) {
return commonBootstrap(appComponentType, componentInjectableBindings);
}

View File

@ -10,7 +10,8 @@ import './interface_query.dart';
* In the future this class will implement an Observable interface.
* For now it uses a plain list of observable callbacks.
*/
class QueryList<T> extends Object with IterableMixin<T> implements IQueryList<T> {
class QueryList<T> extends Object with IterableMixin<T>
implements IQueryList<T> {
List<T> _results = [];
List _callbacks = [];
bool _dirty = false;

View File

@ -11,7 +11,6 @@ typedef void ErrorHandlingFn(error, stackTrace);
* is cancelled.
*/
class WrappedTimer implements Timer {
Timer _timer;
ZeroArgFunction _onCancelCb;
@ -124,7 +123,8 @@ class NgZone {
*
* This hook is useful for validating application state (e.g. in a test).
*/
void overrideOnEventDone(ZeroArgFunction onEventDoneFn, [bool waitForAsync = false]) {
void overrideOnEventDone(ZeroArgFunction onEventDoneFn,
[bool waitForAsync = false]) {
_onEventDone = onEventDoneFn;
if (waitForAsync) {
@ -264,7 +264,8 @@ class NgZone {
}
}
Timer _createTimer(Zone self, ZoneDelegate parent, Zone zone, Duration duration, fn()) {
Timer _createTimer(
Zone self, ZoneDelegate parent, Zone zone, Duration duration, fn()) {
WrappedTimer wrappedTimer;
var cb = () {
fn();

View File

@ -7,40 +7,40 @@ export 'metadata.dart';
* {@link InjectMetadata}.
*/
class Inject extends InjectMetadata {
const Inject(dynamic token): super(token);
const Inject(dynamic token) : super(token);
}
/**
* {@link OptionalMetadata}.
*/
class Optional extends OptionalMetadata {
const Optional(): super();
const Optional() : super();
}
/**
* {@link InjectableMetadata}.
*/
class Injectable extends InjectableMetadata {
const Injectable(): super();
const Injectable() : super();
}
/**
* {@link SelfMetadata}.
*/
class Self extends SelfMetadata {
const Self(): super();
const Self() : super();
}
/**
* {@link AncestorMetadata}.
*/
class Ancestor extends AncestorMetadata {
const Ancestor({bool self}): super(self:self);
const Ancestor({bool self}) : super(self: self);
}
/**
* {@link UnboundedMetadata}.
*/
class Unbounded extends UnboundedMetadata {
const Unbounded({bool self}): super(self:self);
}
const Unbounded({bool self}) : super(self: self);
}

View File

@ -41,16 +41,16 @@ class ObservableListDiff extends IterableChanges {
_updated = false;
return super.transform(collection, args);
// An update has been registered since the last change detection check.
// - We reset the flag.
// - We diff the collection.
} else if (_updated){
// An update has been registered since the last change detection check.
// - We reset the flag.
// - We diff the collection.
} else if (_updated) {
_updated = false;
return super.transform(collection, args);
return super.transform(collection, args);
// No updates has been registered.
// Returning this tells change detection that object has not change,
// so it should NOT update the binding.
// No updates has been registered.
// Returning this tells change detection that object has not change,
// so it should NOT update the binding.
} else {
return this;
}

View File

@ -392,7 +392,6 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
}
var baseElement = null;
String getBaseElementHref() {
if (baseElement == null) {

View File

@ -17,20 +17,25 @@ class Html5LibDomAdapter implements DomAdapter {
return true;
}
void setProperty(Element element, String name, Object value) => throw 'not implemented';
void setProperty(Element element, String name, Object value) =>
throw 'not implemented';
getProperty(Element element, String name) => throw 'not implemented';
invoke(Element element, String methodName, List args) => throw 'not implemented';
invoke(Element element, String methodName, List args) =>
throw 'not implemented';
logError(error) {
stderr.writeln('${error}');
}
log(error) { stdout.writeln('${error}'); }
logGroup(error) { stdout.writeln('${error}'); }
logGroupEnd() { }
log(error) {
stdout.writeln('${error}');
}
logGroup(error) {
stdout.writeln('${error}');
}
logGroupEnd() {}
@override
final attrToPropMap = const {
@ -245,8 +250,8 @@ class Html5LibDomAdapter implements DomAdapter {
}
getAttribute(element, String attribute) {
// `attributes` keys can be {@link AttributeName}s.
var key = element.attributes.keys.firstWhere(
(key) => '$key' == attribute, orElse: () {});
var key = element.attributes.keys.firstWhere((key) => '$key' == attribute,
orElse: () {});
return element.attributes[key];
}
setAttribute(element, String name, String value) {

View File

@ -29,7 +29,8 @@ class PromiseWrapper {
return promise.catchError(onError);
}
static PromiseCompleter<dynamic> completer() => new PromiseCompleter(new Completer());
static PromiseCompleter<dynamic> completer() =>
new PromiseCompleter(new Completer());
}
class TimerWrapper {

View File

@ -4,18 +4,12 @@ import 'package:intl/intl.dart';
String _normalizeLocale(String locale) => locale.replaceAll('-', '_');
enum NumberFormatStyle {
DECIMAL,
PERCENT,
CURRENCY
}
enum NumberFormatStyle { DECIMAL, PERCENT, CURRENCY }
class NumberFormatter {
static String format(num number, String locale, NumberFormatStyle style,
{int minimumIntegerDigits: 1,
int minimumFractionDigits: 0,
int maximumFractionDigits: 3,
String currency,
{int minimumIntegerDigits: 1, int minimumFractionDigits: 0,
int maximumFractionDigits: 3, String currency,
bool currencyAsSymbol: false}) {
locale = _normalizeLocale(locale);
NumberFormat formatter;
@ -29,7 +23,8 @@ class NumberFormatter {
case NumberFormatStyle.CURRENCY:
if (currencyAsSymbol) {
// See https://github.com/dart-lang/intl/issues/59.
throw new Exception('Displaying currency as symbol is not supported.');
throw new Exception(
'Displaying currency as symbol is not supported.');
}
formatter = new NumberFormat.currencyPattern(locale, currency);
break;

View File

@ -201,7 +201,8 @@ class BaseException extends Error {
final originalException;
final originalStack;
BaseException([this.message, this.originalException, this.originalStack, this.context]);
BaseException(
[this.message, this.originalException, this.originalStack, this.context]);
String toString() {
return this.message;

View File

@ -1,4 +1,5 @@
library angular2.src.http.backends.browser_jsonp;
import 'package:angular2/di.dart';
import 'dart:html' show document;
import 'dart:js' show context, JsObject, JsArray;
@ -50,7 +51,9 @@ class BrowserJsonp {
}
// Attach the <script> element to the DOM
send(dynamic node) { document.body.append(node); }
send(dynamic node) {
document.body.append(node);
}
// Remove <script> element from the DOM
cleanup(dynamic node) {

View File

@ -5,7 +5,7 @@ import 'package:angular2/di.dart';
@Injectable()
class BrowserXhr {
HttpRequest build() {
return new HttpRequest();
}
HttpRequest build() {
return new HttpRequest();
}
}

View File

@ -1,4 +1,5 @@
library angular2.src.http.http_utils;
import 'dart:js' show JsObject;
import 'dart:collection' show LinkedHashMap, LinkedHashSet;

View File

@ -49,37 +49,188 @@ class ReflectionCapabilities implements PlatformReflectionCapabilities {
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]).reflectee;
case 11:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) => create(
name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]).reflectee;
case 12:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => create(
name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12
]).reflectee;
case 13:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13]).reflectee;
create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13
]).reflectee;
case 14:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14]).reflectee;
create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14
]).reflectee;
case 15:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15
]).reflectee;
case 16:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16
]).reflectee;
case 17:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17
]).reflectee;
case 18:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17, a18) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18
]).reflectee;
case 19:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19]).
reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17, a18, a19) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18,
a19
]).reflectee;
case 20:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20]).
reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17, a18, a19, a20) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18,
a19,
a20
]).reflectee;
}
throw "Cannot create a factory for '${stringify(type)}' because its constructor has more than 20 arguments";

View File

@ -101,7 +101,8 @@ class Expect extends gns.Expect {
void toThrowErrorWith(message) => expectException(this.actual, message);
void toBePromise() => gns.guinness.matchers.toBeTrue(actual is Future);
void toImplement(expected) => toBeA(expected);
void toBeNaN() => gns.guinness.matchers.toBeTrue(double.NAN.compareTo(actual) == 0);
void toBeNaN() =>
gns.guinness.matchers.toBeTrue(double.NAN.compareTo(actual) == 0);
void toHaveText(expected) => _expect(elementText(actual), expected);
void toHaveBeenCalledWith([a = _u, b = _u, c = _u, d = _u, e = _u, f = _u]) =>
_expect(_argsMatch(actual, a, b, c, d, e, f), true,

View File

@ -78,7 +78,8 @@ class _CodegenState {
_CodegenState._(this._changeDetectorDefId, this._contextTypeName,
this._changeDetectorTypeName, String changeDetectionStrategy,
List<ProtoRecord> records, List<DirectiveRecord> directiveRecords, this._generateCheckNoChanges)
List<ProtoRecord> records, List<DirectiveRecord> directiveRecords,
this._generateCheckNoChanges)
: _records = records,
_directiveRecords = directiveRecords,
_names = new CodegenNameUtil(records, directiveRecords, '_', _UTIL),
@ -92,7 +93,8 @@ class _CodegenState {
.forEach((rec) => protoRecords.add(rec, def.variableNames));
var records = coalesce(protoRecords.records);
return new _CodegenState._(def.id, typeName, changeDetectorTypeName,
def.strategy, records, def.directiveRecords, def.generateCheckNoChanges);
def.strategy, records, def.directiveRecords,
def.generateCheckNoChanges);
}
void _writeToBuf(StringBuffer buf) {

View File

@ -5,8 +5,7 @@ import 'dart:async';
import 'dart:core';
import 'package:angular2/src/web-workers/shared/message_bus.dart'
show MessageBus, MessageBusSink, MessageBusSource;
import 'package:angular2/src/web-workers/ui/impl.dart'
show bootstrapUICommon;
import 'package:angular2/src/web-workers/ui/impl.dart' show bootstrapUICommon;
/**
* Bootstrapping a WebWorker
@ -23,7 +22,7 @@ void bootstrap(String uri) {
/**
* To be called from the main thread to spawn and communicate with the worker thread
*/
Future<UIMessageBus> spawnWorker(Uri uri){
Future<UIMessageBus> spawnWorker(Uri uri) {
var receivePort = new ReceivePort();
var isolateEndSendPort = receivePort.sendPort;
return Isolate.spawnUri(uri, const [], isolateEndSendPort).then((_) {
@ -57,7 +56,8 @@ class UIMessageBusSink extends MessageBusSink {
class UIMessageBusSource extends MessageBusSource {
final ReceivePort _port;
final Stream rawDataStream;
Map<int, StreamSubscription> _listenerStore = new Map<int, StreamSubscription>();
Map<int, StreamSubscription> _listenerStore =
new Map<int, StreamSubscription>();
int _numListeners = 0;
UIMessageBusSource(ReceivePort port)
@ -68,8 +68,8 @@ class UIMessageBusSource extends MessageBusSource {
return message is SendPort;
});
int addListener(Function fn){
var subscription = rawDataStream.listen((message){
int addListener(Function fn) {
var subscription = rawDataStream.listen((message) {
fn({"data": message});
});
@ -77,7 +77,7 @@ class UIMessageBusSource extends MessageBusSource {
return _numListeners;
}
void removeListener(int index){
void removeListener(int index) {
_listenerStore[index].cancel();
_listenerStore.remove(index);
}

View File

@ -3,7 +3,7 @@ library angular2.src.web_workers.worker;
import "package:angular2/src/web-workers/shared/message_bus.dart"
show MessageBus, MessageBusSource, MessageBusSink;
import "package:angular2/src/web-workers/worker/application_common.dart"
show bootstrapWebworkerCommon;
show bootstrapWebworkerCommon;
import "package:angular2/src/facade/async.dart" show Future;
import "package:angular2/src/core/application.dart" show ApplicationRef;
import "package:angular2/src/facade/lang.dart" show Type, BaseException;
@ -27,8 +27,8 @@ Future<ApplicationRef> bootstrapWebworker(
[List<dynamic> componentInjectableBindings = null]) {
ReceivePort rPort = new ReceivePort();
WorkerMessageBus bus = new WorkerMessageBus.fromPorts(replyTo, rPort);
return bootstrapWebworkerCommon(appComponentType, bus,
componentInjectableBindings);
return bootstrapWebworkerCommon(
appComponentType, bus, componentInjectableBindings);
}
class WorkerMessageBus extends MessageBus {
@ -57,15 +57,16 @@ class WorkerMessageBusSink extends MessageBusSink {
class WorkerMessageBusSource extends MessageBusSource {
final ReceivePort _port;
final Stream rawDataStream;
Map<int, StreamSubscription> _listenerStore = new Map<int, StreamSubscription>();
Map<int, StreamSubscription> _listenerStore =
new Map<int, StreamSubscription>();
int _numListeners = 0;
WorkerMessageBusSource(ReceivePort rPort)
: _port = rPort,
rawDataStream = rPort.asBroadcastStream();
int addListener(Function fn){
var subscription = rawDataStream.listen((message){
int addListener(Function fn) {
var subscription = rawDataStream.listen((message) {
fn({"data": message});
});
@ -73,7 +74,7 @@ class WorkerMessageBusSource extends MessageBusSource {
return _numListeners;
}
void removeListener(int index){
void removeListener(int index) {
_listenerStore[index].cancel();
_listenerStore.remove(index);
}