Skip to content

Commit 65fc117

Browse files
committed
refactor: code cleanup
Closes dart-archive#1061
1 parent f54451b commit 65fc117

8 files changed

+16
-19
lines changed

lib/core/annotation_src.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ typedef void DirectiveBinderFn(DirectiveBinder module);
1515

1616
RegExp _ATTR_NAME = new RegExp(r'\[([^\]]+)\]$');
1717

18-
Directive cloneWithNewMap(Directive annotation, map)
19-
=> annotation._cloneWithNewMap(map);
18+
Directive cloneWithNewMap(Directive annotation, map) => annotation._cloneWithNewMap(map);
2019

2120
String mappingSpec(DirectiveAnnotation annotation) => annotation._mappingSpec;
2221

@@ -219,7 +218,8 @@ abstract class Directive {
219218
this.exportExpressionAttrs: const []
220219
});
221220

222-
toString() => selector;
221+
String toString() => selector;
222+
223223
Directive _cloneWithNewMap(newMap);
224224
}
225225

lib/core/formatter.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FormatterMap {
2424
});
2525
}
2626

27-
call(String name) => _injector.get(this[name]);
27+
Function call(String name) => _injector.get(this[name]);
2828

2929
Type operator[](String name) {
3030
Type formatterType = _map[name];

lib/core/interpolate.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class Interpolate implements Function {
6161
// formatter
6262
expParts.add(_wrapInQuotes(template.substring(index, startIdx)));
6363
}
64-
expParts.add('(' + template.substring(startIdx + startLen, endIdx) +
65-
'|stringify)');
64+
expParts.add('(' + template.substring(startIdx + startLen, endIdx) + '|stringify)');
6665

6766
index = endIdx + endLen;
6867
hasInterpolation = true;

lib/core/scope.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class Scope {
217217
} else if (expression.startsWith(':')) {
218218
expression = expression.substring(1);
219219
fn = (value, last) {
220-
if (value != null) reactionFn(value, last);
220+
if (value != null) reactionFn(value, last);
221221
};
222222
}
223223
}

lib/core_dom/common.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
part of angular.core.dom_internal;
22

3-
List<dom.Node> cloneElements(elements) {
4-
return elements.map((el) => el.clone(true)).toList();
5-
}
3+
List<dom.Node> cloneElements(elements) => elements.map((el) => el.clone(true)).toList();
64

75
class MappingParts {
86
final String attrName;
@@ -23,7 +21,7 @@ class DirectiveRef {
2321
final Directive annotation;
2422
final String value;
2523
final AST valueAST;
26-
final mappings = new List<MappingParts>();
24+
final mappings = <MappingParts>[];
2725

2826
DirectiveRef(this.element, type, this.annotation, this.typeKey, [ this.value, this.valueAST ])
2927
: type = type,

lib/core_dom/directive_map.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ class DirectiveTypeTuple {
44
final Directive directive;
55
final Type type;
66
DirectiveTypeTuple(this.directive, this.type);
7-
toString() => '@$directive#$type';
7+
String toString() => '@$directive#$type';
88
}
99

1010
@Injectable()
1111
class DirectiveMap {
1212
final Map<String, List<DirectiveTypeTuple>> map = new HashMap<String, List<DirectiveTypeTuple>>();
13-
DirectiveSelectorFactory _directiveSelectorFactory;
13+
final DirectiveSelectorFactory _directiveSelectorFactory;
1414
FormatterMap _formatters;
1515
DirectiveSelector _selector;
1616

@@ -20,10 +20,10 @@ class DirectiveMap {
2020
this._directiveSelectorFactory) {
2121
(injector as ModuleInjector).types.forEach((type) {
2222
metadataExtractor(type)
23-
.where((annotation) => annotation is Directive)
24-
.forEach((Directive directive) {
25-
map.putIfAbsent(directive.selector, () => []).add(new DirectiveTypeTuple(directive, type));
26-
});
23+
.where((annotation) => annotation is Directive)
24+
.forEach((Directive dir) {
25+
map.putIfAbsent(dir.selector, () => []).add(new DirectiveTypeTuple(dir, type));
26+
});
2727
});
2828
}
2929

lib/core_dom/element_binder.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ElementBinder {
9191
}
9292
}
9393

94-
_bindOneWay(tasks, ast, scope, AST dstAST, controller) {
94+
void _bindOneWay(tasks, ast, scope, AST dstAST, controller) {
9595
var taskId = (tasks != null) ? tasks.registerTask() : 0;
9696

9797
scope.watchAST(ast, (v, _) {

lib/core_dom/node_cursor.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ class NodeCursor {
4545

4646
NodeCursor remove() => new NodeCursor([elements.removeAt(index)..remove()]);
4747

48-
toString() => "[NodeCursor: $elements $index]";
48+
String toString() => "[NodeCursor: $elements $index]";
4949
}

0 commit comments

Comments
 (0)