style(dart): Format with dartfmt v0.2.0
Format all pure Dart code with package:dart_style v0.2.0 Command: ``` find -type f -name "*.dart" | xargs dartformat -w ```
This commit is contained in:
@ -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>
|
||||
class QueryList<T> extends Object
|
||||
with IterableMixin<T>
|
||||
implements IQueryList<T> {
|
||||
List<T> _results = [];
|
||||
List _callbacks = [];
|
||||
|
@ -10,8 +10,17 @@ 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 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);
|
||||
});
|
||||
}
|
||||
@ -88,8 +97,8 @@ class GetTestability {
|
||||
});
|
||||
js.context['getAllAngularTestabilities'] = _jsify(() {
|
||||
List<Testability> testabilities = registry.getAllTestabilities();
|
||||
List<PublicTestability> publicTestabilities =
|
||||
testabilities.map((testability) => new PublicTestability(testability));
|
||||
List<PublicTestability> publicTestabilities = testabilities
|
||||
.map((testability) => new PublicTestability(testability));
|
||||
return _jsify(publicTestabilities);
|
||||
});
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ class NgZone {
|
||||
} else {
|
||||
_innerZone = _createInnerZone(Zone.current,
|
||||
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone,
|
||||
error,
|
||||
StackTrace trace) => _onErrorWithoutLongStackTrace(error, trace));
|
||||
error, StackTrace trace) =>
|
||||
_onErrorWithoutLongStackTrace(error, trace));
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,7 +231,8 @@ class NgZone {
|
||||
_run(self, parent, zone, () => fn(arg));
|
||||
|
||||
dynamic _runBinary(Zone self, ZoneDelegate parent, Zone zone, fn(arg1, arg2),
|
||||
arg1, arg2) => _run(self, parent, zone, () => fn(arg1, arg2));
|
||||
arg1, arg2) =>
|
||||
_run(self, parent, zone, () => fn(arg1, arg2));
|
||||
|
||||
void _scheduleMicrotask(Zone self, ZoneDelegate parent, Zone zone, fn) {
|
||||
_pendingMicrotasks++;
|
||||
|
@ -104,14 +104,15 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
_hasPropertyCache = new Map();
|
||||
_setProperty = js.context.callMethod(
|
||||
'eval', ['(function(el, prop, value) { el[prop] = value; })']);
|
||||
_getProperty = js.context.callMethod(
|
||||
'eval', ['(function(el, prop) { return el[prop]; })']);
|
||||
_hasProperty = js.context.callMethod(
|
||||
'eval', ['(function(el, prop) { return prop in el; })']);
|
||||
_getProperty = js.context
|
||||
.callMethod('eval', ['(function(el, prop) { return el[prop]; })']);
|
||||
_hasProperty = js.context
|
||||
.callMethod('eval', ['(function(el, prop) { return prop in el; })']);
|
||||
}
|
||||
static void makeCurrent() {
|
||||
setRootDomAdapter(new BrowserDomAdapter());
|
||||
}
|
||||
|
||||
bool hasProperty(Element element, String name) {
|
||||
// Always return true as the serverside version html_adapter.dart does so.
|
||||
// TODO: change this once we have schema support.
|
||||
@ -156,10 +157,10 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
|
||||
@override
|
||||
Map<String, String> get attrToPropMap => const <String, String>{
|
||||
'innerHtml': 'innerHTML',
|
||||
'readonly': 'readOnly',
|
||||
'tabindex': 'tabIndex',
|
||||
};
|
||||
'innerHtml': 'innerHTML',
|
||||
'readonly': 'readOnly',
|
||||
'tabindex': 'tabIndex',
|
||||
};
|
||||
|
||||
Element query(String selector) => document.querySelector(selector);
|
||||
|
||||
@ -173,29 +174,35 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
// addEventListener misses zones so we use element.on.
|
||||
element.on[event].listen(callback);
|
||||
}
|
||||
|
||||
Function onAndCancel(EventTarget element, String event, callback(arg)) {
|
||||
// due to https://code.google.com/p/dart/issues/detail?id=17406
|
||||
// addEventListener misses zones so we use element.on.
|
||||
var subscription = element.on[event].listen(callback);
|
||||
return subscription.cancel;
|
||||
}
|
||||
|
||||
void dispatchEvent(EventTarget el, Event evt) {
|
||||
el.dispatchEvent(evt);
|
||||
}
|
||||
|
||||
MouseEvent createMouseEvent(String eventType) =>
|
||||
new MouseEvent(eventType, canBubble: true);
|
||||
Event createEvent(String eventType) => new Event(eventType, canBubble: true);
|
||||
void preventDefault(Event evt) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
||||
bool isPrevented(Event evt) {
|
||||
return evt.defaultPrevented;
|
||||
}
|
||||
|
||||
String getInnerHTML(Element el) => el.innerHtml;
|
||||
String getOuterHTML(Element el) => el.outerHtml;
|
||||
void setInnerHTML(Element el, String value) {
|
||||
el.innerHtml = value;
|
||||
}
|
||||
|
||||
String nodeName(Node el) => el.nodeName;
|
||||
String nodeValue(Node el) => el.nodeValue;
|
||||
String type(InputElement el) => el.type;
|
||||
@ -208,42 +215,54 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
void clearNodes(Node el) {
|
||||
el.nodes = const [];
|
||||
}
|
||||
|
||||
void appendChild(Node el, Node node) {
|
||||
el.append(node);
|
||||
}
|
||||
|
||||
void removeChild(el, Node node) {
|
||||
node.remove();
|
||||
}
|
||||
|
||||
void replaceChild(Node el, Node newNode, Node oldNode) {
|
||||
oldNode.replaceWith(newNode);
|
||||
}
|
||||
|
||||
ChildNode remove(ChildNode el) {
|
||||
return el..remove();
|
||||
}
|
||||
|
||||
void insertBefore(Node el, node) {
|
||||
el.parentNode.insertBefore(node, el);
|
||||
}
|
||||
|
||||
void insertAllBefore(Node el, Iterable<Node> nodes) {
|
||||
el.parentNode.insertAllBefore(nodes, el);
|
||||
}
|
||||
|
||||
void insertAfter(Node el, Node node) {
|
||||
el.parentNode.insertBefore(node, el.nextNode);
|
||||
}
|
||||
|
||||
String getText(Node el) => el.text;
|
||||
void setText(Node el, String value) {
|
||||
el.text = value;
|
||||
}
|
||||
|
||||
String getValue(el) => el.value;
|
||||
void setValue(el, String value) {
|
||||
el.value = value;
|
||||
}
|
||||
|
||||
bool getChecked(InputElement el) => el.checked;
|
||||
void setChecked(InputElement el, bool isChecked) {
|
||||
el.checked = isChecked;
|
||||
}
|
||||
|
||||
Comment createComment(String text) {
|
||||
return new Comment(text);
|
||||
}
|
||||
|
||||
TemplateElement createTemplate(String html) {
|
||||
var t = new TemplateElement();
|
||||
// We do not sanitize because templates are part of the application code
|
||||
@ -251,13 +270,16 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
t.setInnerHtml(html, treeSanitizer: _identitySanitizer);
|
||||
return t;
|
||||
}
|
||||
|
||||
Element createElement(String tagName, [HtmlDocument doc = null]) {
|
||||
if (doc == null) doc = document;
|
||||
return doc.createElement(tagName);
|
||||
}
|
||||
|
||||
Text createTextNode(String text, [HtmlDocument doc = null]) {
|
||||
return new Text(text);
|
||||
}
|
||||
|
||||
createScriptTag(String attrName, String attrValue,
|
||||
[HtmlDocument doc = null]) {
|
||||
if (doc == null) doc = document;
|
||||
@ -265,12 +287,14 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
el.setAttribute(attrName, attrValue);
|
||||
return el;
|
||||
}
|
||||
|
||||
StyleElement createStyleElement(String css, [HtmlDocument doc = null]) {
|
||||
if (doc == null) doc = document;
|
||||
var el = doc.createElement('STYLE');
|
||||
el.text = css;
|
||||
return el;
|
||||
}
|
||||
|
||||
ShadowRoot createShadowRoot(Element el) => el.createShadowRoot();
|
||||
ShadowRoot getShadowRoot(Element el) => el.shadowRoot;
|
||||
Element getHost(Element el) => (el as ShadowRoot).host;
|
||||
@ -283,18 +307,22 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
void addClass(Element element, String classname) {
|
||||
element.classes.add(classname);
|
||||
}
|
||||
|
||||
void removeClass(Element element, String classname) {
|
||||
element.classes.remove(classname);
|
||||
}
|
||||
|
||||
bool hasClass(Element element, String classname) =>
|
||||
element.classes.contains(classname);
|
||||
|
||||
void setStyle(Element element, String stylename, String stylevalue) {
|
||||
element.style.setProperty(stylename, stylevalue);
|
||||
}
|
||||
|
||||
void removeStyle(Element element, String stylename) {
|
||||
element.style.removeProperty(stylename);
|
||||
}
|
||||
|
||||
String getStyle(Element element, String stylename) {
|
||||
return element.style.getPropertyValue(stylename);
|
||||
}
|
||||
@ -332,6 +360,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
void setTitle(String newTitle) {
|
||||
document.title = newTitle;
|
||||
}
|
||||
|
||||
bool elementMatches(n, String selector) =>
|
||||
n is Element && n.matches(selector);
|
||||
bool isTemplateElement(Element el) => el is TemplateElement;
|
||||
@ -341,15 +370,19 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
bool hasShadowRoot(Node node) {
|
||||
return node is Element && node.shadowRoot != null;
|
||||
}
|
||||
|
||||
bool isShadowRoot(Node node) {
|
||||
return node is ShadowRoot;
|
||||
}
|
||||
|
||||
Node importIntoDoc(Node node) {
|
||||
return document.importNode(node, true);
|
||||
}
|
||||
|
||||
Node adoptNode(Node node) {
|
||||
return document.adoptNode(node);
|
||||
}
|
||||
|
||||
bool isPageRule(CssRule rule) => rule is CssPageRule;
|
||||
bool isStyleRule(CssRule rule) => rule is CssStyleRule;
|
||||
bool isMediaRule(CssRule rule) => rule is CssMediaRule;
|
||||
@ -357,12 +390,14 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
String getHref(AnchorElement element) {
|
||||
return element.href;
|
||||
}
|
||||
|
||||
String getEventKey(KeyboardEvent event) {
|
||||
int keyCode = event.keyCode;
|
||||
return _keyCodeToKeyMap.containsKey(keyCode)
|
||||
? _keyCodeToKeyMap[keyCode]
|
||||
: 'Unidentified';
|
||||
}
|
||||
|
||||
getGlobalEventTarget(String target) {
|
||||
if (target == "window") {
|
||||
return window;
|
||||
@ -372,12 +407,15 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
return document.body;
|
||||
}
|
||||
}
|
||||
|
||||
getHistory() {
|
||||
return window.history;
|
||||
}
|
||||
|
||||
getLocation() {
|
||||
return window.location;
|
||||
}
|
||||
|
||||
getBaseHref() {
|
||||
var href = getBaseElementHref();
|
||||
if (href == null) {
|
||||
@ -386,15 +424,19 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
var baseUri = Uri.parse(href);
|
||||
return baseUri.path;
|
||||
}
|
||||
|
||||
String getUserAgent() {
|
||||
return window.navigator.userAgent;
|
||||
}
|
||||
|
||||
void setData(Element element, String name, String value) {
|
||||
element.dataset[name] = value;
|
||||
}
|
||||
|
||||
String getData(Element element, String name) {
|
||||
return element.dataset[name];
|
||||
}
|
||||
|
||||
// TODO(tbosch): move this into a separate environment class once we have it
|
||||
setGlobalVar(String name, value) {
|
||||
js.context[name] = value;
|
||||
|
@ -32,9 +32,11 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
log(error) {
|
||||
stdout.writeln('${error}');
|
||||
}
|
||||
|
||||
logGroup(error) {
|
||||
stdout.writeln('${error}');
|
||||
}
|
||||
|
||||
logGroupEnd() {}
|
||||
|
||||
@override
|
||||
@ -78,39 +80,51 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
query(selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
querySelector(el, String selector) {
|
||||
return el.querySelector(selector);
|
||||
}
|
||||
|
||||
List querySelectorAll(el, String selector) {
|
||||
return el.querySelectorAll(selector);
|
||||
}
|
||||
|
||||
on(el, evt, listener) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
Function onAndCancel(el, evt, listener) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
dispatchEvent(el, evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createMouseEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
preventDefault(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
isPrevented(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getInnerHTML(el) {
|
||||
return el.innerHtml;
|
||||
}
|
||||
|
||||
getOuterHTML(el) {
|
||||
return el.outerHtml;
|
||||
}
|
||||
|
||||
String nodeName(node) {
|
||||
switch (node.nodeType) {
|
||||
case Node.ELEMENT_NODE:
|
||||
@ -123,10 +137,12 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
' for node types definitions.';
|
||||
}
|
||||
}
|
||||
|
||||
String nodeValue(node) => node.data;
|
||||
String type(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
content(node) {
|
||||
return node;
|
||||
}
|
||||
@ -147,81 +163,103 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
parentElement(el) {
|
||||
return el.parent;
|
||||
}
|
||||
|
||||
List childNodes(el) => el.nodes;
|
||||
List childNodesAsList(el) => el.nodes;
|
||||
clearNodes(el) {
|
||||
el.nodes.forEach((e) => e.remove());
|
||||
}
|
||||
|
||||
appendChild(el, node) => el.append(node.remove());
|
||||
removeChild(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
remove(el) => el.remove();
|
||||
insertBefore(el, node) {
|
||||
if (el.parent == null) throw '$el must have a parent';
|
||||
el.parent.insertBefore(node, el);
|
||||
}
|
||||
|
||||
insertAllBefore(el, nodes) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
insertAfter(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setInnerHTML(el, value) {
|
||||
el.innerHtml = value;
|
||||
}
|
||||
|
||||
getText(el) {
|
||||
return el.text;
|
||||
}
|
||||
|
||||
setText(el, String value) => el.text = value;
|
||||
|
||||
getValue(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setValue(el, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getChecked(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setChecked(el, bool value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createComment(String text) => new Comment(text);
|
||||
createTemplate(String html) => createElement('template')..innerHtml = html;
|
||||
createElement(tagName, [doc]) {
|
||||
return new Element.tag(tagName);
|
||||
}
|
||||
|
||||
createTextNode(String text, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createScriptTag(String attrName, String attrValue, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createStyleElement(String css, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createShadowRoot(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getShadowRoot(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getHost(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
clone(node) => node.clone(true);
|
||||
getElementsByClassName(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getElementsByTagName(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List classList(element) => element.classes.toList();
|
||||
|
||||
addClass(element, String classname) {
|
||||
element.classes.add(classname);
|
||||
}
|
||||
|
||||
removeClass(element, String classname) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
@ -231,9 +269,11 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
setStyle(element, String stylename, String stylevalue) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeStyle(element, String stylename) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getStyle(element, String stylename) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
@ -248,19 +288,23 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
hasAttribute(element, String attribute) {
|
||||
// `attributes` keys can be {@link AttributeName}s.
|
||||
return element.attributes.keys.any((key) => '$key' == attribute);
|
||||
}
|
||||
|
||||
getAttribute(element, String attribute) {
|
||||
// `attributes` keys can be {@link AttributeName}s.
|
||||
var key = element.attributes.keys.firstWhere((key) => '$key' == attribute,
|
||||
orElse: () {});
|
||||
return element.attributes[key];
|
||||
}
|
||||
|
||||
setAttribute(element, String name, String value) {
|
||||
element.attributes[name] = value;
|
||||
}
|
||||
|
||||
removeAttribute(element, String attribute) {
|
||||
element.attributes.remove(attribute);
|
||||
}
|
||||
@ -282,6 +326,7 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
bool isTemplateElement(Element el) {
|
||||
return el != null && el.localName.toLowerCase() == 'template';
|
||||
}
|
||||
|
||||
bool isTextNode(node) => node.nodeType == Node.TEXT_NODE;
|
||||
bool isCommentNode(node) => node.nodeType == Node.COMMENT_NODE;
|
||||
|
||||
@ -290,63 +335,83 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
bool hasShadowRoot(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isShadowRoot(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
importIntoDoc(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
adoptNode(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isPageRule(rule) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isStyleRule(rule) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isMediaRule(rule) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isKeyframesRule(rule) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getHref(element) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
void resolveAndSetHref(element, baseUrl, href) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List cssToRules(String css) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List getDistributedNodes(Node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool supportsDOMEvents() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supportsNativeShadowDOM() {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHistory() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getLocation() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getBaseHref() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getUserAgent() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
void setData(Element element, String name, String value) {
|
||||
this.setAttribute(element, 'data-${name}', value);
|
||||
}
|
||||
|
||||
String getData(Element element, String name) {
|
||||
return this.getAttribute(element, 'data-${name}');
|
||||
}
|
||||
|
||||
// TODO(tbosch): move this into a separate environment class once we have it
|
||||
setGlobalVar(String name, value) {
|
||||
// noop on the server
|
||||
|
@ -46,6 +46,7 @@ class TimerWrapper {
|
||||
fn();
|
||||
});
|
||||
}
|
||||
|
||||
static void clearInterval(Timer timer) {
|
||||
timer.cancel();
|
||||
}
|
||||
|
@ -42,22 +42,25 @@ class MapWrapper {
|
||||
static Map toStringMap(Map m) => m;
|
||||
|
||||
static Map createFromPairs(List pairs) => pairs.fold({}, (m, p) {
|
||||
m[p[0]] = p[1];
|
||||
return m;
|
||||
});
|
||||
m[p[0]] = p[1];
|
||||
return m;
|
||||
});
|
||||
static forEach(Map m, fn(v, k)) {
|
||||
m.forEach((k, v) => fn(v, k));
|
||||
}
|
||||
|
||||
static get(Map map, key) => map[key];
|
||||
static int size(Map m) => m.length;
|
||||
static void delete(Map m, k) {
|
||||
m.remove(k);
|
||||
}
|
||||
|
||||
static void clearValues(Map m) {
|
||||
for (var k in m.keys) {
|
||||
m[k] = null;
|
||||
}
|
||||
}
|
||||
|
||||
static Iterable iterable(Map m) => new IterableMap(m);
|
||||
static List keys(Map m) => m.keys.toList();
|
||||
static List values(Map m) => m.values.toList();
|
||||
@ -70,12 +73,15 @@ class StringMapWrapper {
|
||||
static void set(Map map, key, value) {
|
||||
map[key] = value;
|
||||
}
|
||||
|
||||
static void delete(Map m, k) {
|
||||
m.remove(k);
|
||||
}
|
||||
|
||||
static void forEach(Map m, fn(v, k)) {
|
||||
m.forEach((k, v) => fn(v, k));
|
||||
}
|
||||
|
||||
static Map merge(Map a, Map b) {
|
||||
var m = new Map.from(a);
|
||||
if (b != null) {
|
||||
@ -83,9 +89,11 @@ class StringMapWrapper {
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
static List<String> keys(Map<String, dynamic> a) {
|
||||
return a.keys.toList();
|
||||
}
|
||||
|
||||
static bool isEmpty(Map m) => m.isEmpty;
|
||||
static bool equals(Map m1, Map m2) {
|
||||
if (m1.length != m2.length) {
|
||||
@ -111,6 +119,7 @@ class ListWrapper {
|
||||
static void set(List m, int k, v) {
|
||||
m[k] = v;
|
||||
}
|
||||
|
||||
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();
|
||||
@ -124,9 +133,11 @@ class ListWrapper {
|
||||
static void forEach(Iterable list, fn(item)) {
|
||||
list.forEach(fn);
|
||||
}
|
||||
|
||||
static reduce(List list, fn(a, b), init) {
|
||||
return list.fold(init, fn);
|
||||
}
|
||||
|
||||
static first(List list) => list.isEmpty ? null : list.first;
|
||||
static last(List list) => list.isEmpty ? null : list.last;
|
||||
static List reversed(List list) => list.reversed.toList();
|
||||
@ -136,25 +147,30 @@ class ListWrapper {
|
||||
..setRange(0, a.length, a)
|
||||
..setRange(a.length, a.length + b.length, b);
|
||||
}
|
||||
|
||||
static void insert(List l, int index, value) {
|
||||
l.insert(index, value);
|
||||
}
|
||||
|
||||
static removeAt(List l, int index) => l.removeAt(index);
|
||||
static void removeAll(List list, List items) {
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
list.remove(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static removeLast(List list) => list.removeLast();
|
||||
static bool remove(List list, item) => list.remove(item);
|
||||
static void clear(List l) {
|
||||
l.clear();
|
||||
}
|
||||
|
||||
static String join(List l, String s) => l.join(s);
|
||||
static bool isEmpty(Iterable list) => list.isEmpty;
|
||||
static void fill(List l, value, [int start = 0, int end]) {
|
||||
l.fillRange(_startOffset(l, start), _endOffset(l, end), value);
|
||||
}
|
||||
|
||||
static bool equals(List a, List b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
@ -162,9 +178,11 @@ class ListWrapper {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static List slice(List l, [int from = 0, int to]) {
|
||||
return l.sublist(_startOffset(l, from), _endOffset(l, to));
|
||||
}
|
||||
|
||||
static List splice(List l, int from, int length) {
|
||||
from = _startOffset(l, from);
|
||||
var to = from + length;
|
||||
@ -172,6 +190,7 @@ class ListWrapper {
|
||||
l.removeRange(from, to);
|
||||
return sub;
|
||||
}
|
||||
|
||||
static void sort(List l, [compareFn(a, b) = null]) {
|
||||
if (compareFn == null) {
|
||||
l.sort();
|
||||
|
@ -8,8 +8,10 @@ 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;
|
||||
|
@ -20,9 +20,11 @@ int ENUM_INDEX(value) => value.index;
|
||||
class CONST {
|
||||
const CONST();
|
||||
}
|
||||
|
||||
class ABSTRACT {
|
||||
const ABSTRACT();
|
||||
}
|
||||
|
||||
class IMPLEMENTS {
|
||||
final interfaceClass;
|
||||
const IMPLEMENTS(this.interfaceClass);
|
||||
@ -161,12 +163,15 @@ class RegExpWrapper {
|
||||
return new RegExp(regExpStr,
|
||||
multiLine: multiLine, caseSensitive: caseSensitive);
|
||||
}
|
||||
|
||||
static Match firstMatch(RegExp regExp, String input) {
|
||||
return regExp.firstMatch(input);
|
||||
}
|
||||
|
||||
static bool test(RegExp regExp, String input) {
|
||||
return regExp.hasMatch(input);
|
||||
}
|
||||
|
||||
static Iterator<Match> matcher(RegExp regExp, String input) {
|
||||
return regExp.allMatches(input).iterator;
|
||||
}
|
||||
@ -263,19 +268,28 @@ class Json {
|
||||
}
|
||||
|
||||
class DateWrapper {
|
||||
static DateTime create(int year, [int month = 1, int day = 1, int hour = 0,
|
||||
int minutes = 0, int seconds = 0, int milliseconds = 0]) {
|
||||
static DateTime create(int year,
|
||||
[int month = 1,
|
||||
int day = 1,
|
||||
int hour = 0,
|
||||
int minutes = 0,
|
||||
int seconds = 0,
|
||||
int milliseconds = 0]) {
|
||||
return new DateTime(year, month, day, hour, minutes, seconds, milliseconds);
|
||||
}
|
||||
|
||||
static DateTime fromMillis(int ms) {
|
||||
return new DateTime.fromMillisecondsSinceEpoch(ms, isUtc: true);
|
||||
}
|
||||
|
||||
static int toMillis(DateTime date) {
|
||||
return date.millisecondsSinceEpoch;
|
||||
}
|
||||
|
||||
static DateTime now() {
|
||||
return new DateTime.now();
|
||||
}
|
||||
|
||||
static String toJson(DateTime date) {
|
||||
return date.toUtc().toIso8601String();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ var context = null;
|
||||
var _trace;
|
||||
var _events;
|
||||
var _createScope;
|
||||
var _leaveScope;
|
||||
var _leaveScope;
|
||||
var _beginTimeRange;
|
||||
var _endTimeRange;
|
||||
final List _arg1 = [null];
|
||||
@ -39,14 +39,14 @@ int getArgSize(String signature) {
|
||||
int end = signature.indexOf(')', start);
|
||||
bool found = false;
|
||||
int count = 0;
|
||||
for(var i = start; i < end; i++) {
|
||||
for (var i = start; i < end; i++) {
|
||||
var ch = signature[i];
|
||||
if (identical(ch, ',')) {
|
||||
found = false;
|
||||
}
|
||||
if (!found) {
|
||||
found = true;
|
||||
count ++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
@ -56,24 +56,24 @@ dynamic createScope(String signature, [flags]) {
|
||||
_arg2[0] = signature;
|
||||
_arg2[1] = flags;
|
||||
var jsScope = _createScope.apply(_arg2, thisArg: _events);
|
||||
switch(getArgSize(signature)) {
|
||||
switch (getArgSize(signature)) {
|
||||
case 0:
|
||||
return ([arg0, arg1]) {
|
||||
return jsScope.apply(const []);
|
||||
};
|
||||
return ([arg0, arg1]) {
|
||||
return jsScope.apply(const []);
|
||||
};
|
||||
case 1:
|
||||
return ([arg0, arg1]) {
|
||||
_arg1[0] = arg0;
|
||||
return jsScope.apply(_arg1);
|
||||
};
|
||||
return ([arg0, arg1]) {
|
||||
_arg1[0] = arg0;
|
||||
return jsScope.apply(_arg1);
|
||||
};
|
||||
case 2:
|
||||
return ([arg0, arg1]) {
|
||||
_arg2[0] = arg0;
|
||||
_arg2[1] = arg1;
|
||||
return jsScope.apply(_arg1);
|
||||
};
|
||||
return ([arg0, arg1]) {
|
||||
_arg2[0] = arg0;
|
||||
_arg2[1] = arg1;
|
||||
return jsScope.apply(_arg1);
|
||||
};
|
||||
default:
|
||||
throw "Max 2 arguments are supported.";
|
||||
throw "Max 2 arguments are supported.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,188 +49,183 @@ 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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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";
|
||||
|
@ -30,9 +30,13 @@ class HammerGesturesPlugin extends HammerGesturesPluginCommon {
|
||||
var mc = new js.JsObject(js.context['Hammer'], [element]);
|
||||
|
||||
var jsObj = mc.callMethod('get', ['pinch']);
|
||||
jsObj.callMethod('set', [new js.JsObject.jsify({'enable': true})]);
|
||||
jsObj.callMethod('set', [
|
||||
new js.JsObject.jsify({'enable': true})
|
||||
]);
|
||||
jsObj = mc.callMethod('get', ['rotate']);
|
||||
jsObj.callMethod('set', [new js.JsObject.jsify({'enable': true})]);
|
||||
jsObj.callMethod('set', [
|
||||
new js.JsObject.jsify({'enable': true})
|
||||
]);
|
||||
|
||||
mc.callMethod('on', [
|
||||
eventName,
|
||||
|
@ -23,25 +23,25 @@ Function fakeAsync(Function fn) {
|
||||
throw 'fakeAsync() calls can not be nested';
|
||||
}
|
||||
|
||||
return ([a0 = _u, a1 = _u, a2 = _u, a3 = _u, a4 = _u, a5 = _u, a6 = _u,
|
||||
a7 = _u, a8 = _u, a9 = _u]) {
|
||||
return (
|
||||
[a0 = _u,
|
||||
a1 = _u,
|
||||
a2 = _u,
|
||||
a3 = _u,
|
||||
a4 = _u,
|
||||
a5 = _u,
|
||||
a6 = _u,
|
||||
a7 = _u,
|
||||
a8 = _u,
|
||||
a9 = _u]) {
|
||||
// runZoned() to install a custom exception handler that re-throws
|
||||
return runZoned(() {
|
||||
return new quiver.FakeAsync().run((quiver.FakeAsync async) {
|
||||
try {
|
||||
_fakeAsync = async;
|
||||
List args = [
|
||||
a0,
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9
|
||||
].takeWhile((a) => a != _u).toList();
|
||||
List args = [a0, a1, a2, a3, a4, a5, a6, a7, a8, a9]
|
||||
.takeWhile((a) => a != _u)
|
||||
.toList();
|
||||
var res = Function.apply(fn, args);
|
||||
_fakeAsync.flushMicrotasks();
|
||||
|
||||
@ -84,8 +84,7 @@ void tick([int millis = 0]) {
|
||||
* This is not needed in Dart. Because quiver correctly removes a timer when
|
||||
* it throws an exception.
|
||||
*/
|
||||
void clearPendingTimers() {
|
||||
}
|
||||
void clearPendingTimers() {}
|
||||
|
||||
/**
|
||||
* Flush any pending microtasks.
|
||||
|
@ -35,6 +35,7 @@ class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {
|
||||
}
|
||||
|
||||
@proxy
|
||||
class SpyIterableDifferFactory extends SpyObject implements IterableDifferFactory {
|
||||
class SpyIterableDifferFactory extends SpyObject
|
||||
implements IterableDifferFactory {
|
||||
noSuchMethod(m) => super.noSuchMethod(m);
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ class AnnotationMatcher extends ClassMatcherBase {
|
||||
ClassDescriptor descriptor = firstMatch(annotation.name, assetId);
|
||||
if (descriptor == null) return false;
|
||||
return implements(descriptor, interfaces,
|
||||
missingSuperClassWarning: 'Missing `custom_annotation` entry for `${descriptor.superClass}`.');
|
||||
missingSuperClassWarning:
|
||||
'Missing `custom_annotation` entry for `${descriptor.superClass}`.');
|
||||
}
|
||||
|
||||
/// Checks if an [Annotation] node implements [Injectable].
|
||||
|
@ -48,8 +48,8 @@ abstract class ClassMatcherBase {
|
||||
if (descriptor == null) return false;
|
||||
if (interfaces.contains(descriptor)) return true;
|
||||
if (descriptor.superClass == null) return false;
|
||||
var superClass = _classDescriptors.firstWhere(
|
||||
(a) => a.name == descriptor.superClass, orElse: () => null);
|
||||
var superClass = _classDescriptors
|
||||
.firstWhere((a) => a.name == descriptor.superClass, orElse: () => null);
|
||||
if (superClass == null) {
|
||||
if (missingSuperClassWarning != null &&
|
||||
missingSuperClassWarning.isNotEmpty) {
|
||||
@ -74,7 +74,8 @@ ImportDirective _getMatchingImport(
|
||||
name = className.name;
|
||||
}
|
||||
if (name != descriptor.name) return null;
|
||||
return (className.root as CompilationUnit).directives
|
||||
return (className.root as CompilationUnit)
|
||||
.directives
|
||||
.where((d) => d is ImportDirective)
|
||||
.firstWhere((ImportDirective i) {
|
||||
var importMatch = false;
|
||||
@ -106,8 +107,10 @@ bool isMatch(
|
||||
class ClassDescriptor {
|
||||
/// The name of the class.
|
||||
final String name;
|
||||
|
||||
/// A `package:` style import path to the file where the class is defined.
|
||||
final String import;
|
||||
|
||||
/// The class that this class extends or implements. This is the only optional
|
||||
/// field.
|
||||
final String superClass;
|
||||
|
@ -108,7 +108,8 @@ class _DirectiveMetadataVisitor extends Object
|
||||
var directiveType = _getDirectiveType('${node.name}', node.element);
|
||||
if (directiveType >= 0) {
|
||||
if (_hasMeta) {
|
||||
throw new FormatException('Only one Directive is allowed per class. '
|
||||
throw new FormatException(
|
||||
'Only one Directive is allowed per class. '
|
||||
'Found "$node" but already processed "$meta".',
|
||||
'$node' /* source */);
|
||||
}
|
||||
@ -125,7 +126,8 @@ class _DirectiveMetadataVisitor extends Object
|
||||
'${node.constructorName.type.name}', node.staticElement);
|
||||
if (directiveType >= 0) {
|
||||
if (_hasMeta) {
|
||||
throw new FormatException('Only one Directive is allowed per class. '
|
||||
throw new FormatException(
|
||||
'Only one Directive is allowed per class. '
|
||||
'Found "$node" but already processed "$meta".',
|
||||
'$node' /* source */);
|
||||
}
|
||||
@ -177,8 +179,10 @@ class _DirectiveMetadataVisitor extends Object
|
||||
String _expressionToString(Expression node, String nodeDescription) {
|
||||
var value = node.accept(_evaluator);
|
||||
if (value is! String) {
|
||||
throw new FormatException('Angular 2 could not understand the value '
|
||||
'in $nodeDescription.', '$node' /* source */);
|
||||
throw new FormatException(
|
||||
'Angular 2 could not understand the value '
|
||||
'in $nodeDescription.',
|
||||
'$node' /* source */);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -203,7 +207,8 @@ class _DirectiveMetadataVisitor extends Object
|
||||
if (evaluated is! bool) {
|
||||
throw new FormatException(
|
||||
'Angular 2 expects a bool but could not understand the value for '
|
||||
'Directive#compileChildren.', '$compileChildrenValue' /* source */);
|
||||
'Directive#compileChildren.',
|
||||
'$compileChildrenValue' /* source */);
|
||||
}
|
||||
_compileChildren = evaluated;
|
||||
}
|
||||
@ -216,7 +221,8 @@ class _DirectiveMetadataVisitor extends Object
|
||||
if (evaluated is! Map) {
|
||||
throw new FormatException(
|
||||
'Angular 2 expects a Map but could not understand the value for '
|
||||
'$propertyName.', '$expression' /* source */);
|
||||
'$propertyName.',
|
||||
'$expression' /* source */);
|
||||
}
|
||||
evaluated.forEach((key, value) {
|
||||
if (value != null) {
|
||||
@ -233,7 +239,8 @@ class _DirectiveMetadataVisitor extends Object
|
||||
if (evaluated is! List) {
|
||||
throw new FormatException(
|
||||
'Angular 2 expects a List but could not understand the value for '
|
||||
'$propertyName.', '$expression' /* source */);
|
||||
'$propertyName.',
|
||||
'$expression' /* source */);
|
||||
}
|
||||
list.addAll(evaluated);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class PrintLogger implements BuildLogger {
|
||||
void error(msg, {AssetId asset, SourceSpan span}) {
|
||||
throw new PrintLoggerError(msg, asset, span);
|
||||
}
|
||||
|
||||
Future writeOutput() => null;
|
||||
Future addLogFilesFromAsset(AssetId id, [int nextNumber = 1]) => null;
|
||||
}
|
||||
|
@ -51,25 +51,41 @@ class TransformerOptions {
|
||||
/// The "correct" number of phases varies with the structure of the app.
|
||||
final int optimizationPhases;
|
||||
|
||||
TransformerOptions._internal(this.entryPoints, this.reflectionEntryPoints,
|
||||
this.modeName, this.mirrorMode, this.initReflector,
|
||||
this.annotationMatcher, this.optimizationPhases,
|
||||
this.generateChangeDetectors, this.inlineViews);
|
||||
TransformerOptions._internal(
|
||||
this.entryPoints,
|
||||
this.reflectionEntryPoints,
|
||||
this.modeName,
|
||||
this.mirrorMode,
|
||||
this.initReflector,
|
||||
this.annotationMatcher,
|
||||
this.optimizationPhases,
|
||||
this.generateChangeDetectors,
|
||||
this.inlineViews);
|
||||
|
||||
factory TransformerOptions(List<String> entryPoints,
|
||||
{List<String> reflectionEntryPoints, String modeName: 'release',
|
||||
MirrorMode mirrorMode: MirrorMode.none, bool initReflector: true,
|
||||
{List<String> reflectionEntryPoints,
|
||||
String modeName: 'release',
|
||||
MirrorMode mirrorMode: MirrorMode.none,
|
||||
bool initReflector: true,
|
||||
List<ClassDescriptor> customAnnotationDescriptors: const [],
|
||||
int optimizationPhases: DEFAULT_OPTIMIZATION_PHASES,
|
||||
bool inlineViews: true, bool generateChangeDetectors: true}) {
|
||||
bool inlineViews: true,
|
||||
bool generateChangeDetectors: true}) {
|
||||
if (reflectionEntryPoints == null || reflectionEntryPoints.isEmpty) {
|
||||
reflectionEntryPoints = entryPoints;
|
||||
}
|
||||
var annotationMatcher = new AnnotationMatcher()
|
||||
..addAll(customAnnotationDescriptors);
|
||||
optimizationPhases = optimizationPhases.isNegative ? 0 : optimizationPhases;
|
||||
return new TransformerOptions._internal(entryPoints, reflectionEntryPoints,
|
||||
modeName, mirrorMode, initReflector, annotationMatcher,
|
||||
optimizationPhases, generateChangeDetectors, inlineViews);
|
||||
return new TransformerOptions._internal(
|
||||
entryPoints,
|
||||
reflectionEntryPoints,
|
||||
modeName,
|
||||
mirrorMode,
|
||||
initReflector,
|
||||
annotationMatcher,
|
||||
optimizationPhases,
|
||||
generateChangeDetectors,
|
||||
inlineViews);
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,16 @@ import 'package:angular2/src/transform/common/names.dart';
|
||||
class RegisteredType {
|
||||
/// The type registered by this call.
|
||||
final Identifier typeName;
|
||||
|
||||
/// The actual call to `Reflector#registerType`.
|
||||
final MethodInvocation registerMethod;
|
||||
|
||||
/// The factory method registered.
|
||||
final Expression factoryFn;
|
||||
|
||||
/// The parameters registered.
|
||||
final Expression parameters;
|
||||
|
||||
/// The annotations registered.
|
||||
final Expression annotations;
|
||||
|
||||
|
@ -44,8 +44,8 @@ class Rewriter {
|
||||
visitor.loadLibraryInvocations.sort(compare);
|
||||
|
||||
var buf = new StringBuffer();
|
||||
var idx = visitor.deferredImports.fold(0,
|
||||
(int lastIdx, ImportDirective node) {
|
||||
var idx =
|
||||
visitor.deferredImports.fold(0, (int lastIdx, ImportDirective node) {
|
||||
buf.write(code.substring(lastIdx, node.offset));
|
||||
|
||||
var import = code.substring(node.offset, node.end);
|
||||
@ -120,8 +120,7 @@ class _FindDeferredLibraries extends Object with RecursiveAstVisitor<Object> {
|
||||
.map((asset) => _reader.hasInput(asset)));
|
||||
|
||||
// Filter out any deferred imports that do not have ng_deps.
|
||||
deferredImports = it
|
||||
.zip([deferredImports, hasInputs])
|
||||
deferredImports = it.zip([deferredImports, hasInputs])
|
||||
.where((importHasInput) => importHasInput[1])
|
||||
.map((importHasInput) => importHasInput[0])
|
||||
.toList();
|
||||
|
@ -116,5 +116,6 @@ Future<Map<UriBasedDirective, String>> _processNgImports(AssetReader reader,
|
||||
retVal[directive] = ngDepsUri;
|
||||
}
|
||||
}, onError: (_) => null);
|
||||
})).then((_) => retVal);
|
||||
}))
|
||||
.then((_) => retVal);
|
||||
}
|
||||
|
@ -30,9 +30,14 @@ Future<String> createNgDeps(AssetReader reader, AssetId assetId,
|
||||
// TODO(kegluneq): Shortcut if we can determine that there are no
|
||||
// [Directive]s present, taking into account `export`s.
|
||||
var writer = new AsyncStringWriter();
|
||||
var visitor = new CreateNgDepsVisitor(writer, assetId,
|
||||
new XhrImpl(reader, assetId), annotationMatcher, _interfaceMatcher,
|
||||
ngMeta, inlineViews: inlineViews);
|
||||
var visitor = new CreateNgDepsVisitor(
|
||||
writer,
|
||||
assetId,
|
||||
new XhrImpl(reader, assetId),
|
||||
annotationMatcher,
|
||||
_interfaceMatcher,
|
||||
ngMeta,
|
||||
inlineViews: inlineViews);
|
||||
var code = await reader.readAsString(assetId);
|
||||
parseCompilationUnit(code, name: assetId.path).accept(visitor);
|
||||
|
||||
@ -76,9 +81,14 @@ class CreateNgDepsVisitor extends Object with SimpleAstVisitor<Object> {
|
||||
/// The assetId for the file which we are parsing.
|
||||
final AssetId assetId;
|
||||
|
||||
CreateNgDepsVisitor(AsyncStringWriter writer, AssetId assetId, XHR xhr,
|
||||
AnnotationMatcher annotationMatcher, InterfaceMatcher interfaceMatcher,
|
||||
this.ngMeta, {bool inlineViews})
|
||||
CreateNgDepsVisitor(
|
||||
AsyncStringWriter writer,
|
||||
AssetId assetId,
|
||||
XHR xhr,
|
||||
AnnotationMatcher annotationMatcher,
|
||||
InterfaceMatcher interfaceMatcher,
|
||||
this.ngMeta,
|
||||
{bool inlineViews})
|
||||
: writer = writer,
|
||||
_copyVisitor = new ToSourceVisitor(writer),
|
||||
_factoryVisitor = new FactoryTransformVisitor(writer),
|
||||
|
@ -124,6 +124,7 @@ class _CtorTransformVisitor extends ToSourceVisitor {
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
/// Overridden to avoid outputting grouping operators for default parameters.
|
||||
Object visitFormalParameterList(FormalParameterList node) {
|
||||
writer.print('(');
|
||||
|
@ -9,6 +9,7 @@ class Codegen {
|
||||
|
||||
/// The prefix used to import our generated file.
|
||||
final String prefix;
|
||||
|
||||
/// The import uris
|
||||
final Iterable<String> importUris;
|
||||
|
||||
|
@ -16,8 +16,10 @@ class Rewriter {
|
||||
final MirrorMode _mirrorMode;
|
||||
final bool _writeStaticInit;
|
||||
|
||||
Rewriter(this._code, this._codegen, {AstTester tester,
|
||||
MirrorMode mirrorMode: MirrorMode.none, bool writeStaticInit: true})
|
||||
Rewriter(this._code, this._codegen,
|
||||
{AstTester tester,
|
||||
MirrorMode mirrorMode: MirrorMode.none,
|
||||
bool writeStaticInit: true})
|
||||
: _mirrorMode = mirrorMode,
|
||||
_writeStaticInit = writeStaticInit,
|
||||
_tester = tester == null ? const AstTester() : tester;
|
||||
@ -132,9 +134,8 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||
'Found bootstrap${node.argumentList}. Transform may not succeed.');
|
||||
}
|
||||
|
||||
var reflectorInit = _setupAdded
|
||||
? ''
|
||||
: ', () { ${_getStaticReflectorInitBlock()} }';
|
||||
var reflectorInit =
|
||||
_setupAdded ? '' : ', () { ${_getStaticReflectorInitBlock()} }';
|
||||
|
||||
// rewrite `bootstrap(...)` to `bootstrapStatic(...)`
|
||||
buf.write('bootstrapStatic(${args[0]}');
|
||||
|
@ -18,8 +18,10 @@ import 'package:angular2/src/facade/lang.dart' show BaseException;
|
||||
class Codegen {
|
||||
/// Stores the generated class definitions.
|
||||
final StringBuffer _buf = new StringBuffer();
|
||||
|
||||
/// Stores all generated initialization code.
|
||||
final StringBuffer _initBuf = new StringBuffer();
|
||||
|
||||
/// The names of already generated classes.
|
||||
final Set<String> _names = new Set<String>();
|
||||
|
||||
@ -78,12 +80,18 @@ class _CodegenState {
|
||||
final CodegenNameUtil _names;
|
||||
final bool _generateCheckNoChanges;
|
||||
|
||||
_CodegenState._(this._changeDetectorDefId, this._contextTypeName,
|
||||
this._changeDetectorTypeName, String changeDetectionStrategy,
|
||||
this._records, this._directiveRecords, this._logic, this._names,
|
||||
_CodegenState._(
|
||||
this._changeDetectorDefId,
|
||||
this._contextTypeName,
|
||||
this._changeDetectorTypeName,
|
||||
String changeDetectionStrategy,
|
||||
this._records,
|
||||
this._directiveRecords,
|
||||
this._logic,
|
||||
this._names,
|
||||
this._generateCheckNoChanges)
|
||||
: _changeDetectionMode = ChangeDetectionUtil
|
||||
.changeDetectionMode(changeDetectionStrategy);
|
||||
: _changeDetectionMode =
|
||||
ChangeDetectionUtil.changeDetectionMode(changeDetectionStrategy);
|
||||
|
||||
factory _CodegenState(String typeName, String changeDetectorTypeName,
|
||||
ChangeDetectorDefinition def) {
|
||||
@ -92,8 +100,15 @@ class _CodegenState {
|
||||
var protoRecords = coalesce(recBuilder.records);
|
||||
var names = new CodegenNameUtil(protoRecords, def.directiveRecords, _UTIL);
|
||||
var logic = new CodegenLogicUtil(names, _UTIL);
|
||||
return new _CodegenState._(def.id, typeName, changeDetectorTypeName,
|
||||
def.strategy, protoRecords, def.directiveRecords, logic, names,
|
||||
return new _CodegenState._(
|
||||
def.id,
|
||||
typeName,
|
||||
changeDetectorTypeName,
|
||||
def.strategy,
|
||||
protoRecords,
|
||||
def.directiveRecords,
|
||||
logic,
|
||||
names,
|
||||
def.generateCheckNoChanges);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ Future<String> processTemplates(AssetReader reader, AssetId entryPoint,
|
||||
// Note: TemplateCloner(-1) never serializes Nodes into strings.
|
||||
// we might want to change this to TemplateCloner(0) to force the serialization
|
||||
// later when the transformer also stores the proto view template.
|
||||
var extractor = new _TemplateExtractor(
|
||||
new DomElementSchemaRegistry(), new TemplateCloner(-1), new XhrImpl(reader, entryPoint));
|
||||
var extractor = new _TemplateExtractor(new DomElementSchemaRegistry(),
|
||||
new TemplateCloner(-1), new XhrImpl(reader, entryPoint));
|
||||
|
||||
var registrations = new reg.Codegen();
|
||||
var changeDetectorClasses = new change.Codegen();
|
||||
@ -93,7 +93,8 @@ class _TemplateExtractor {
|
||||
ElementSchemaRegistry _schemaRegistry;
|
||||
TemplateCloner _templateCloner;
|
||||
|
||||
_TemplateExtractor(ElementSchemaRegistry schemaRegistry, TemplateCloner templateCloner, XHR xhr)
|
||||
_TemplateExtractor(ElementSchemaRegistry schemaRegistry,
|
||||
TemplateCloner templateCloner, XHR xhr)
|
||||
: _factory = new CompileStepFactory(new ng.Parser(new ng.Lexer())) {
|
||||
var urlResolver = new UrlResolver();
|
||||
var styleUrlResolver = new StyleUrlResolver(urlResolver);
|
||||
@ -120,10 +121,12 @@ class _TemplateExtractor {
|
||||
var pipeline = new CompilePipeline(_factory.createSteps(viewDef));
|
||||
|
||||
var compileElements = pipeline.processElements(
|
||||
DOM.createTemplate(templateAndStyles.template), ViewType.COMPONENT,
|
||||
DOM.createTemplate(templateAndStyles.template),
|
||||
ViewType.COMPONENT,
|
||||
viewDef);
|
||||
var protoViewDto =
|
||||
compileElements[0].inheritedProtoView.build(_schemaRegistry, _templateCloner);
|
||||
var protoViewDto = compileElements[0]
|
||||
.inheritedProtoView
|
||||
.build(_schemaRegistry, _templateCloner);
|
||||
|
||||
reflector.reflectionCapabilities = savedReflectionCapabilities;
|
||||
|
||||
|
@ -39,8 +39,10 @@ _nullMethod(Object p, List a) => null;
|
||||
class RecordingReflectionCapabilities extends NullReflectionCapabilities {
|
||||
/// The names of all requested `getter`s.
|
||||
final Set<String> getterNames = new Set<String>();
|
||||
|
||||
/// The names of all requested `setter`s.
|
||||
final Set<String> setterNames = new Set<String>();
|
||||
|
||||
/// The names of all requested `method`s.
|
||||
final Set<String> methodNames = new Set<String>();
|
||||
|
||||
|
@ -65,8 +65,8 @@ class UIMessageBusSource extends MessageBusSource {
|
||||
rawDataStream = port.asBroadcastStream();
|
||||
|
||||
Future<SendPort> get sink => rawDataStream.firstWhere((message) {
|
||||
return message is SendPort;
|
||||
});
|
||||
return message is SendPort;
|
||||
});
|
||||
|
||||
int addListener(Function fn) {
|
||||
var subscription = rawDataStream.listen((message) {
|
||||
|
@ -63,8 +63,16 @@ final Map EVENT_PROPERTIES = {
|
||||
|
||||
// List of all elements with HTML value attribute.
|
||||
// Taken from: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
||||
final Set<String> NODES_WITH_VALUE =
|
||||
new Set<String>.from(["input", "select", "option", "button", "li", "meter", "progress", "param"]);
|
||||
final Set<String> NODES_WITH_VALUE = new Set<String>.from([
|
||||
"input",
|
||||
"select",
|
||||
"option",
|
||||
"button",
|
||||
"li",
|
||||
"meter",
|
||||
"progress",
|
||||
"param"
|
||||
]);
|
||||
|
||||
Map<String, dynamic> serializeGenericEvent(dynamic e) {
|
||||
return serializeEvent(e, EVENT_PROPERTIES);
|
||||
@ -76,6 +84,7 @@ Map<String, dynamic> serializeEventWithValue(dynamic e) {
|
||||
var serializedEvent = serializeEvent(e, EVENT_PROPERTIES);
|
||||
return addValue(e, serializedEvent);
|
||||
}
|
||||
|
||||
Map<String, dynamic> serializeMouseEvent(dynamic e) {
|
||||
return serializeEvent(e, MOUSE_EVENT_PROPERTIES);
|
||||
}
|
||||
@ -87,7 +96,7 @@ Map<String, dynamic> serializeKeyboardEvent(dynamic e) {
|
||||
|
||||
// TODO(jteplitz602): #3374. See above.
|
||||
Map<String, dynamic> addValue(dynamic e, Map<String, dynamic> serializedEvent) {
|
||||
if (NODES_WITH_VALUE.contains(e.target.tagName.toLowerCase())){
|
||||
if (NODES_WITH_VALUE.contains(e.target.tagName.toLowerCase())) {
|
||||
serializedEvent['target'] = {'value': e.target.value};
|
||||
}
|
||||
return serializedEvent;
|
||||
|
@ -31,10 +31,10 @@ class GenericEvent {
|
||||
Point get page => _getPoint('page');
|
||||
Point get screen => _getPoint('screen');
|
||||
|
||||
EventTarget get target{
|
||||
if (_target != null){
|
||||
EventTarget get target {
|
||||
if (_target != null) {
|
||||
return _target;
|
||||
} else if (properties.containsKey("target")){
|
||||
} else if (properties.containsKey("target")) {
|
||||
_target = new EventTarget(properties['target']);
|
||||
return _target;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user