chore: dartfmt Dart code in the repo
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
library change_detectoin.change_detection_jit_generator;
|
||||
|
||||
class ChangeDetectorJITGenerator {
|
||||
ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {
|
||||
}
|
||||
ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {}
|
||||
|
||||
generate() {
|
||||
throw "Jit Change Detection is not supported in Dart";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ class BaseQueryList extends Object with IterableMixin<Directive> {
|
||||
List _callbacks;
|
||||
bool _dirty;
|
||||
|
||||
BaseQueryList(): _results = [], _callbacks = [], _dirty = false;
|
||||
BaseQueryList()
|
||||
: _results = [],
|
||||
_callbacks = [],
|
||||
_dirty = false;
|
||||
|
||||
Iterator<Directive> get iterator => _results.iterator;
|
||||
|
||||
|
@ -10,16 +10,14 @@ import 'dart:js' as js;
|
||||
// Proxies a Dart function that accepts up to 10 parameters.
|
||||
js.JsFunction _jsFunction(Function fn) {
|
||||
const Object X = __varargSentinel;
|
||||
return new js.JsFunction.withThis(
|
||||
(thisArg, [o1=X, o2=X, o3=X, o4=X, o5=X, o6=X, o7=X, o8=X, o9=X, o10=X]) {
|
||||
return __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10);
|
||||
});
|
||||
return new js.JsFunction.withThis((thisArg, [o1 = X, o2 = X, o3 = X, o4 = X,
|
||||
o5 = X, o6 = X, o7 = X, o8 = X, o9 = X, o10 = X]) {
|
||||
return __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const Object __varargSentinel = const Object();
|
||||
|
||||
|
||||
__invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) {
|
||||
var args = [o1, o2, o3, o4, o5, o6, o7, o8, o9, o10];
|
||||
while (args.length > 0 && identical(args.last, __varargSentinel)) {
|
||||
@ -28,7 +26,6 @@ __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) {
|
||||
return _jsify(Function.apply(fn, args));
|
||||
}
|
||||
|
||||
|
||||
// Helper function to JSify a Dart object. While this is *required* to JSify
|
||||
// the result of a scope.eval(), other uses are not required and are used to
|
||||
// work around http://dartbug.com/17752 in a convenient way (that bug affects
|
||||
@ -44,8 +41,9 @@ _jsify(var obj) {
|
||||
return _jsFunction(obj);
|
||||
}
|
||||
if ((obj is Map) || (obj is Iterable)) {
|
||||
var mappedObj = (obj is Map) ?
|
||||
new Map.fromIterables(obj.keys, obj.values.map(_jsify)) : obj.map(_jsify);
|
||||
var mappedObj = (obj is Map)
|
||||
? new Map.fromIterables(obj.keys, obj.values.map(_jsify))
|
||||
: obj.map(_jsify);
|
||||
if (obj is List) {
|
||||
return new js.JsArray.from(mappedObj);
|
||||
} else {
|
||||
@ -75,10 +73,9 @@ class PublicTestability implements _JsObjectProxyable {
|
||||
|
||||
js.JsObject _toJsObject() {
|
||||
return _jsify({
|
||||
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
|
||||
findBindings(bindingString, exactMatch, allowNonElementNodes),
|
||||
'whenStable': (callback) =>
|
||||
whenStable(() => callback.apply([])),
|
||||
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
|
||||
findBindings(bindingString, exactMatch, allowNonElementNodes),
|
||||
'whenStable': (callback) => whenStable(() => callback.apply([])),
|
||||
})..['_dart_'] = this;
|
||||
}
|
||||
}
|
||||
@ -86,8 +83,8 @@ class PublicTestability implements _JsObjectProxyable {
|
||||
class GetTestability {
|
||||
static addToWindow(TestabilityRegistry registry) {
|
||||
js.context['getAngularTestability'] = _jsify((Element elem) {
|
||||
Testability testability = registry.findTestabilityInTree(elem);
|
||||
return _jsify(new PublicTestability(testability));
|
||||
});
|
||||
Testability testability = registry.findTestabilityInTree(elem);
|
||||
return _jsify(new PublicTestability(testability));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,8 @@ class VmTurnZone {
|
||||
* @param {Function} onScheduleMicrotask
|
||||
* @param {Function} onErrorHandler called when an exception is thrown by a macro or micro task
|
||||
*/
|
||||
initCallbacks({Function onTurnStart, Function onTurnDone, Function onScheduleMicrotask, Function onErrorHandler}) {
|
||||
initCallbacks({Function onTurnStart, Function onTurnDone,
|
||||
Function onScheduleMicrotask, Function onErrorHandler}) {
|
||||
this._onTurnStart = onTurnStart;
|
||||
this._onTurnDone = onTurnDone;
|
||||
this._onScheduleMicrotask = onScheduleMicrotask;
|
||||
@ -111,17 +112,19 @@ class VmTurnZone {
|
||||
}
|
||||
|
||||
async.Zone _createInnerZone(async.Zone zone) {
|
||||
return zone.fork(specification: new async.ZoneSpecification(
|
||||
run: _onRun,
|
||||
runUnary: _onRunUnary,
|
||||
scheduleMicrotask: _onMicrotask
|
||||
));
|
||||
return zone.fork(
|
||||
specification: new async.ZoneSpecification(
|
||||
run: _onRun,
|
||||
runUnary: _onRunUnary,
|
||||
scheduleMicrotask: _onMicrotask));
|
||||
}
|
||||
|
||||
dynamic _onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
|
||||
dynamic _onRunBase(
|
||||
async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
|
||||
_nestedRunCounter++;
|
||||
try {
|
||||
if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(zone, _onTurnStart);
|
||||
if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(
|
||||
zone, _onTurnStart);
|
||||
return fn();
|
||||
} catch (e, s) {
|
||||
if (_onErrorHandler != null && _nestedRunCounter == 1) {
|
||||
@ -131,21 +134,24 @@ class VmTurnZone {
|
||||
}
|
||||
} finally {
|
||||
_nestedRunCounter--;
|
||||
if (_nestedRunCounter == 0 && _onTurnDone != null) _finishTurn(zone, delegate);
|
||||
if (_nestedRunCounter == 0 && _onTurnDone != null) _finishTurn(
|
||||
zone, delegate);
|
||||
}
|
||||
}
|
||||
|
||||
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
|
||||
_onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
|
||||
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
|
||||
fn()) => _onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
|
||||
|
||||
dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn(args), args) =>
|
||||
dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate,
|
||||
async.Zone zone, fn(args), args) =>
|
||||
_onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args));
|
||||
|
||||
void _finishTurn(zone, delegate) {
|
||||
delegate.run(zone, _onTurnDone);
|
||||
}
|
||||
|
||||
_onMicrotask(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn) {
|
||||
_onMicrotask(
|
||||
async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn) {
|
||||
if (this._onScheduleMicrotask != null) {
|
||||
_onScheduleMicrotask(fn);
|
||||
} else {
|
||||
|
@ -2,4 +2,4 @@ library angular2.di.decorators;
|
||||
|
||||
/* This file is empty because, Dart does not have decorators. */
|
||||
|
||||
export 'annotations.dart';
|
||||
export 'annotations.dart';
|
||||
|
@ -33,8 +33,10 @@ class PromiseWrapper {
|
||||
}
|
||||
|
||||
class ObservableWrapper {
|
||||
static StreamSubscription subscribe(Stream s, Function onNext, [onError, onComplete]) {
|
||||
return s.listen(onNext, onError: onError, onDone: onComplete, cancelOnError: true);
|
||||
static StreamSubscription subscribe(Stream s, Function onNext,
|
||||
[onError, onComplete]) {
|
||||
return s.listen(onNext,
|
||||
onError: onError, onDone: onComplete, cancelOnError: true);
|
||||
}
|
||||
|
||||
static bool isObservable(obs) {
|
||||
@ -65,14 +67,10 @@ class EventEmitter extends Stream {
|
||||
_controller = new StreamController.broadcast();
|
||||
}
|
||||
|
||||
StreamSubscription listen(void onData(String line), {
|
||||
void onError(Error error),
|
||||
void onDone(),
|
||||
bool cancelOnError }) {
|
||||
StreamSubscription listen(void onData(String line),
|
||||
{void onError(Error error), void onDone(), bool cancelOnError}) {
|
||||
return _controller.stream.listen(onData,
|
||||
onError: onError,
|
||||
onDone: onDone,
|
||||
cancelOnError: cancelOnError);
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
|
||||
void add(value) {
|
||||
@ -88,7 +86,6 @@ class EventEmitter extends Stream {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class _Completer {
|
||||
final Completer c;
|
||||
|
||||
|
@ -6,15 +6,16 @@ library angular2.src.facade.browser;
|
||||
|
||||
import 'dart:js' show context;
|
||||
|
||||
export 'dart:html' show
|
||||
document,
|
||||
location,
|
||||
window,
|
||||
Element,
|
||||
Node,
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
Event;
|
||||
export 'dart:html'
|
||||
show
|
||||
document,
|
||||
location,
|
||||
window,
|
||||
Element,
|
||||
Node,
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
Event;
|
||||
|
||||
final _gc = context['gc'];
|
||||
|
||||
|
@ -70,7 +70,7 @@ class StringMapWrapper {
|
||||
map[key] = value;
|
||||
}
|
||||
static void delete(Map m, k) {
|
||||
m.remove(k);
|
||||
m.remove(k);
|
||||
}
|
||||
static void forEach(Map m, fn(v, k)) {
|
||||
m.forEach((k, v) => fn(v, k));
|
||||
@ -96,7 +96,8 @@ class ListWrapper {
|
||||
static bool contains(List m, k) => m.contains(k);
|
||||
static List map(list, fn(item)) => list.map(fn).toList();
|
||||
static List filter(List list, bool fn(item)) => list.where(fn).toList();
|
||||
static int indexOf(List list, value, [int startIndex = 0]) => list.indexOf(value, startIndex);
|
||||
static int indexOf(List list, value, [int startIndex = 0]) =>
|
||||
list.indexOf(value, startIndex);
|
||||
static int lastIndexOf(List list, value, [int startIndex = null]) =>
|
||||
list.lastIndexOf(value, startIndex == null ? list.length : startIndex);
|
||||
static find(List list, bool fn(item)) =>
|
||||
@ -115,7 +116,9 @@ class ListWrapper {
|
||||
l.add(e);
|
||||
}
|
||||
static List concat(List a, List b) {
|
||||
return []..addAll(a)..addAll(b);
|
||||
return []
|
||||
..addAll(a)
|
||||
..addAll(b);
|
||||
}
|
||||
static bool isList(l) => l is List;
|
||||
static void insert(List l, int index, value) {
|
||||
@ -154,7 +157,7 @@ class ListWrapper {
|
||||
l.removeRange(from, to);
|
||||
return sub;
|
||||
}
|
||||
static void sort(List l, compareFn(a,b)) {
|
||||
static void sort(List l, compareFn(a, b)) {
|
||||
l.sort(compareFn);
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,8 @@ class RegExpWrapper {
|
||||
static RegExp create(regExpStr, [String flags = '']) {
|
||||
bool multiLine = flags.contains('m');
|
||||
bool caseSensitive = !flags.contains('i');
|
||||
return new RegExp(regExpStr, multiLine: multiLine, caseSensitive: caseSensitive);
|
||||
return new RegExp(regExpStr,
|
||||
multiLine: multiLine, caseSensitive: caseSensitive);
|
||||
}
|
||||
static Match firstMatch(RegExp regExp, String input) {
|
||||
return regExp.firstMatch(input);
|
||||
@ -147,7 +148,7 @@ class _JSLikeMatch {
|
||||
|
||||
_JSLikeMatch(this._m);
|
||||
|
||||
String operator[](index) => _m[index];
|
||||
String operator [](index) => _m[index];
|
||||
int get index => _m.start;
|
||||
int get length => _m.groupCount + 1;
|
||||
}
|
||||
|
@ -11,14 +11,17 @@ class HammerGesturesPlugin extends HammerGesturesPluginCommon {
|
||||
if (!super.supports(eventName)) return false;
|
||||
|
||||
if (!js.context.hasProperty('Hammer')) {
|
||||
throw new BaseException('Hammer.js is not loaded, can not bind ${eventName} event');
|
||||
throw new BaseException(
|
||||
'Hammer.js is not loaded, can not bind ${eventName} event');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
addEventListener(Element element, String eventName, Function handler, bool shouldSupportBubble) {
|
||||
if (shouldSupportBubble) throw new BaseException('Hammer.js plugin does not support bubbling gestures.');
|
||||
addEventListener(Element element, String eventName, Function handler,
|
||||
bool shouldSupportBubble) {
|
||||
if (shouldSupportBubble) throw new BaseException(
|
||||
'Hammer.js plugin does not support bubbling gestures.');
|
||||
var zone = this.manager.getZone();
|
||||
eventName = eventName.toLowerCase();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
library angular2.src.services.xhr_impl;
|
||||
library angular2.src.services.xhr_impl;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
@ -9,8 +9,7 @@ import './xhr.dart' show XHR;
|
||||
class XHRImpl extends XHR {
|
||||
Future<String> get(String url) {
|
||||
return HttpRequest.request(url).then(
|
||||
(HttpRequest request) => request.responseText,
|
||||
onError: (Error e) => throw 'Failed to load $url'
|
||||
);
|
||||
(HttpRequest request) => request.responseText,
|
||||
onError: (Error e) => throw 'Failed to load $url');
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
library test_lib.test_lib;
|
||||
|
||||
import 'package:guinness/guinness.dart' as gns;
|
||||
export 'package:guinness/guinness.dart' hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
|
||||
export 'package:guinness/guinness.dart'
|
||||
hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
|
||||
import 'package:unittest/unittest.dart' hide expect;
|
||||
|
||||
import 'dart:async';
|
||||
@ -42,12 +43,9 @@ void testSetup() {
|
||||
// - Priority 2: collect the bindings before each test, see beforeEachBindings(),
|
||||
// - Priority 1: create the test injector to be used in beforeEach() and it()
|
||||
|
||||
gns.beforeEach(
|
||||
() {
|
||||
_testBindings.clear();
|
||||
},
|
||||
priority: 3
|
||||
);
|
||||
gns.beforeEach(() {
|
||||
_testBindings.clear();
|
||||
}, priority: 3);
|
||||
|
||||
var completerBinding = bind(AsyncTestCompleter).toFactory(() {
|
||||
// Mark the test as async when an AsyncTestCompleter is injected in an it(),
|
||||
@ -56,14 +54,11 @@ void testSetup() {
|
||||
return new AsyncTestCompleter();
|
||||
});
|
||||
|
||||
gns.beforeEach(
|
||||
() {
|
||||
_isCurrentTestAsync = false;
|
||||
_testBindings.add(completerBinding);
|
||||
_injector = createTestInjector(_testBindings);
|
||||
},
|
||||
priority: 1
|
||||
);
|
||||
gns.beforeEach(() {
|
||||
_isCurrentTestAsync = false;
|
||||
_testBindings.add(completerBinding);
|
||||
_injector = createTestInjector(_testBindings);
|
||||
}, priority: 1);
|
||||
}
|
||||
|
||||
Expect expect(actual, [matcher]) {
|
||||
@ -80,13 +75,14 @@ class Expect extends gns.Expect {
|
||||
NotExpect get not => new NotExpect(actual);
|
||||
|
||||
void toEqual(expected) => toHaveSameProps(expected);
|
||||
void toThrowError([message=""]) => toThrowWith(message: message);
|
||||
void toThrowError([message = ""]) => toThrowWith(message: message);
|
||||
void toBePromise() => _expect(actual is Future, equals(true));
|
||||
void toImplement(expected) => toBeA(expected);
|
||||
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
|
||||
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, reason: 'method invoked with correct arguments');
|
||||
_expect(_argsMatch(actual, a, b, c, d, e, f), true,
|
||||
reason: 'method invoked with correct arguments');
|
||||
Function get _expect => gns.guinness.matchers.expect;
|
||||
|
||||
// TODO(tbosch): move this hack into Guinness
|
||||
@ -97,7 +93,7 @@ class Expect extends gns.Expect {
|
||||
return false;
|
||||
} else {
|
||||
gns.SamePropsMatcher matcher = new gns.SamePropsMatcher(toMatch);
|
||||
for (var i=0; i<calls.length; i++) {
|
||||
for (var i = 0; i < calls.length; i++) {
|
||||
var call = calls[i];
|
||||
// TODO: create a better error message, not just 'Expected: <true> Actual: <false>'.
|
||||
// For hacking this is good:
|
||||
@ -141,13 +137,10 @@ void beforeEach(fn) {
|
||||
* ]);
|
||||
*/
|
||||
void beforeEachBindings(Function fn) {
|
||||
gns.beforeEach(
|
||||
() {
|
||||
var bindings = fn();
|
||||
if (bindings != null) _testBindings.addAll(bindings);
|
||||
},
|
||||
priority: 2
|
||||
);
|
||||
gns.beforeEach(() {
|
||||
var bindings = fn();
|
||||
if (bindings != null) _testBindings.addAll(bindings);
|
||||
}, priority: 2);
|
||||
}
|
||||
|
||||
void _it(gnsFn, name, fn) {
|
||||
@ -160,7 +153,6 @@ void _it(gnsFn, name, fn) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void it(name, fn) {
|
||||
_it(gns.it, name, fn);
|
||||
}
|
||||
@ -174,7 +166,7 @@ void xit(name, fn) {
|
||||
}
|
||||
|
||||
class SpyFunction extends gns.SpyFunction {
|
||||
SpyFunction(String name): super(name);
|
||||
SpyFunction(String name) : super(name);
|
||||
|
||||
// TODO: vsavkin move to guinness
|
||||
andReturn(value) {
|
||||
@ -185,10 +177,10 @@ class SpyFunction extends gns.SpyFunction {
|
||||
class SpyObject extends gns.SpyObject {
|
||||
final Map<String, SpyFunction> _spyFuncs = {};
|
||||
|
||||
SpyObject([arg]){}
|
||||
SpyObject([arg]) {}
|
||||
|
||||
SpyFunction spy(String funcName) =>
|
||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||
|
||||
static stub([object = null, config = null, overrides = null]) {
|
||||
if (object is! SpyObject) {
|
||||
@ -198,15 +190,13 @@ class SpyObject extends gns.SpyObject {
|
||||
}
|
||||
|
||||
var m = StringMapWrapper.merge(config, overrides);
|
||||
StringMapWrapper.forEach(m, (value, key){
|
||||
StringMapWrapper.forEach(m, (value, key) {
|
||||
object.spy(key).andReturn(value);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String elementText(n) {
|
||||
hasNodes(n) {
|
||||
var children = DOM.childNodes(n);
|
||||
|
@ -1 +1 @@
|
||||
library util_decorators;
|
||||
library util_decorators;
|
||||
|
Reference in New Issue
Block a user