Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 3ee8740

Browse files
technohippymhevery
authored andcommitted
style: rename Filter to Formatter
Closes #983
1 parent ecf9b71 commit 3ee8740

20 files changed

+114
-115
lines changed

lib/core/annotation_src.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,21 +553,21 @@ abstract class DetachAware {
553553
* Usage:
554554
*
555555
* // Declaration
556-
* @Formatter(name:'myFilter')
557-
* class MyFilter {
558-
* call(valueToFilter, optArg1, optArg2) {
556+
* @Formatter(name:'myFormatter')
557+
* class MyFormatter {
558+
* call(valueToFormat, optArg1, optArg2) {
559559
* return ...;
560560
* }
561561
* }
562562
*
563563
*
564564
* // Registration
565565
* var module = ...;
566-
* module.type(MyFilter);
566+
* module.type(MyFormatter);
567567
*
568568
*
569569
* <!-- Usage -->
570-
* <span>{{something | myFilter:arg1:arg2}}</span>
570+
* <span>{{something | myFormatter:arg1:arg2}}</span>
571571
*/
572572
class Formatter {
573573
final String name;

lib/core/formatter.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class FormatterMap extends AnnotationMap<Formatter> {
1212
super(injector, extractMetadata);
1313

1414
call(String name) {
15-
var filter = new Formatter(name: name);
16-
var filterType = this[filter];
17-
return _injector.get(filterType);
15+
var formatter = new Formatter(name: name);
16+
var formatterType = this[formatter];
17+
return _injector.get(formatterType);
1818
}
1919
}
2020

lib/core/module.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export "package:angular/core_dom/module_internal.dart" show
6161
export "package:angular/core/module_internal.dart" show
6262
CacheStats,
6363
ExceptionHandler,
64-
FilterMap,
6564
Interpolate,
6665
VmTurnZone,
6766
PrototypeMap,

lib/core/module_internal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export 'package:angular/change_detection/watch_group.dart';
1818
import 'package:angular/change_detection/change_detection.dart';
1919
import 'package:angular/change_detection/dirty_checking_change_detector.dart';
2020
import 'package:angular/core/parser/utils.dart';
21-
import 'package:angular/core/parser/syntax.dart';
21+
import 'package:angular/core/parser/syntax.dart' as syntax;
2222
import 'package:angular/core/registry.dart';
2323

2424
part "cache.dart";

lib/core/parser/dynamic_parser.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
library angular.core.parser.dynamic_parser;
22

3-
import 'package:angular/core/annotation_src.dart';
3+
import 'package:angular/core/annotation_src.dart' hide Formatter;
44
import 'package:angular/core/module_internal.dart' show FormatterMap;
55

66
import 'package:angular/core/parser/parser.dart';
@@ -72,11 +72,11 @@ class DynamicParserBackend extends ParserBackend {
7272

7373
bool isAssignable(Expression expression) => expression.isAssignable;
7474

75-
Expression newFilter(expression, name, arguments) {
75+
Expression newFormatter(expression, name, arguments) {
7676
List allArguments = new List(arguments.length + 1);
7777
allArguments[0] = expression;
7878
allArguments.setAll(1, arguments);
79-
return new Filter(expression, name, arguments, allArguments);
79+
return new Formatter(expression, name, arguments, allArguments);
8080
}
8181

8282
Expression newChain(expressions) => new Chain(expressions);

lib/core/parser/dynamic_parser_impl.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ class DynamicParserImpl {
3232
next.isCharacter($RBRACKET)) {
3333
error('Unconsumed token $next');
3434
}
35-
var expr = parseFilter();
35+
var expr = parseFormatter();
3636
expressions.add(expr);
3737
while (optionalCharacter($SEMICOLON)) {
3838
isChain = true;
3939
}
40-
if (isChain && expr is Filter) {
40+
if (isChain && expr is Formatter) {
4141
error('Cannot have a formatter in a chain');
4242
}
4343
if (!isChain && index < tokens.length) {
@@ -49,7 +49,7 @@ class DynamicParserImpl {
4949
: backend.newChain(expressions);
5050
}
5151

52-
parseFilter() {
52+
parseFormatter() {
5353
var result = parseExpression();
5454
while (optionalOperator('|')) {
5555
String name = expectIdentifierOrKeyword();
@@ -58,7 +58,7 @@ class DynamicParserImpl {
5858
// TODO(kasperl): Is this really supposed to be expressions?
5959
arguments.add(parseExpression());
6060
}
61-
result = backend.newFilter(result, name, arguments);
61+
result = backend.newFormatter(result, name, arguments);
6262
}
6363
return result;
6464
}
@@ -217,7 +217,7 @@ class DynamicParserImpl {
217217

218218
parsePrimary() {
219219
if (optionalCharacter($LPAREN)) {
220-
var result = parseFilter();
220+
var result = parseFormatter();
221221
expectCharacter($RPAREN);
222222
return result;
223223
} else if (next.isKeywordNull || next.isKeywordUndefined) {

lib/core/parser/eval.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class Chain extends syntax.Chain {
1919
}
2020
}
2121

22-
class Filter extends syntax.Filter {
22+
class Formatter extends syntax.Formatter {
2323
final List<syntax.Expression> allArguments;
24-
Filter(syntax.Expression expression, String name, List<syntax.Expression> arguments,
24+
Formatter(syntax.Expression expression, String name, List<syntax.Expression> arguments,
2525
this.allArguments)
2626
: super(expression, name, arguments);
2727

lib/core/parser/parser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class ParserBackend<T> {
2323
bool isAssignable(T expression);
2424

2525
T newChain(List expressions) => null;
26-
T newFilter(T expression, String name, List arguments) => null;
26+
T newFormatter(T expression, String name, List arguments) => null;
2727

2828
T newAssign(T target, T value) => null;
2929
T newConditional(T condition, T yes, T no) => null;

lib/core/parser/syntax.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ abstract class Visitor {
1010

1111
visitExpression(Expression expression) => null;
1212
visitChain(Chain expression) => visitExpression(expression);
13-
visitFilter(Filter expression) => visitExpression(expression);
13+
visitFormatter(Formatter expression) => visitExpression(expression);
1414

1515
visitAssign(Assign expression) => visitExpression(expression);
1616
visitConditional(Conditional expression) => visitExpression(expression);
@@ -73,12 +73,12 @@ class Chain extends Expression {
7373
accept(Visitor visitor) => visitor.visitChain(this);
7474
}
7575

76-
class Filter extends Expression {
76+
class Formatter extends Expression {
7777
final Expression expression;
7878
final String name;
7979
final List<Expression> arguments;
80-
Filter(this.expression, this.name, this.arguments);
81-
accept(Visitor visitor) => visitor.visitFilter(this);
80+
Formatter(this.expression, this.name, this.arguments);
81+
accept(Visitor visitor) => visitor.visitFormatter(this);
8282
}
8383

8484
class Assign extends Expression {

lib/core/parser/unparser.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class Unparser extends Visitor {
4141
}
4242
}
4343

44-
void visitFilter(Filter filter) {
44+
void visitFormatter(Formatter formatter) {
4545
write('(');
46-
visit(filter.expression);
47-
write('|${filter.name}');
48-
for (int i = 0; i < filter.arguments.length; i++) {
46+
visit(formatter.expression);
47+
write('|${formatter.name}');
48+
for (int i = 0; i < formatter.arguments.length; i++) {
4949
write(' :');
50-
visit(filter.arguments[i]);
50+
visit(formatter.arguments[i]);
5151
}
5252
write(')');
5353
}

lib/core/scope.dart

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ class _AstParser {
10611061
}
10621062
}
10631063

1064-
class ExpressionVisitor implements Visitor {
1064+
class ExpressionVisitor implements syntax.Visitor {
10651065
static final ContextReferenceAST scopeContextRef = new ContextReferenceAST();
10661066
final ClosureMap _closureMap;
10671067
AST contextRef = scopeContextRef;
@@ -1072,7 +1072,7 @@ class ExpressionVisitor implements Visitor {
10721072
AST ast;
10731073
FormatterMap formatters;
10741074

1075-
AST visit(Expression exp) {
1075+
AST visit(syntax.Expression exp) {
10761076
exp.accept(this);
10771077
assert(ast != null);
10781078
try {
@@ -1082,68 +1082,68 @@ class ExpressionVisitor implements Visitor {
10821082
}
10831083
}
10841084

1085-
AST visitCollection(Expression exp) => new CollectionAST(visit(exp));
1086-
AST _mapToAst(Expression expression) => visit(expression);
1085+
AST visitCollection(syntax.Expression exp) => new CollectionAST(visit(exp));
1086+
AST _mapToAst(syntax.Expression expression) => visit(expression);
10871087

1088-
List<AST> _toAst(List<Expression> expressions) =>
1088+
List<AST> _toAst(List<syntax.Expression> expressions) =>
10891089
expressions.map(_mapToAst).toList();
10901090

1091-
Map<Symbol, AST> _toAstMap(Map<String, Expression> expressions) {
1091+
Map<Symbol, AST> _toAstMap(Map<String, syntax.Expression> expressions) {
10921092
if (expressions.isEmpty) return const {};
10931093
Map<Symbol, AST> result = new Map<Symbol, AST>();
1094-
expressions.forEach((String name, Expression expression) {
1094+
expressions.forEach((String name, syntax.Expression expression) {
10951095
result[_closureMap.lookupSymbol(name)] = _mapToAst(expression);
10961096
});
10971097
return result;
10981098
}
10991099

1100-
void visitCallScope(CallScope exp) {
1100+
void visitCallScope(syntax.CallScope exp) {
11011101
List<AST> positionals = _toAst(exp.arguments.positionals);
11021102
Map<Symbol, AST> named = _toAstMap(exp.arguments.named);
11031103
ast = new MethodAST(contextRef, exp.name, positionals, named);
11041104
}
1105-
void visitCallMember(CallMember exp) {
1105+
void visitCallMember(syntax.CallMember exp) {
11061106
List<AST> positionals = _toAst(exp.arguments.positionals);
11071107
Map<Symbol, AST> named = _toAstMap(exp.arguments.named);
11081108
ast = new MethodAST(visit(exp.object), exp.name, positionals, named);
11091109
}
1110-
visitAccessScope(AccessScope exp) {
1110+
void visitAccessScope(syntax.AccessScope exp) {
11111111
ast = new FieldReadAST(contextRef, exp.name);
11121112
}
1113-
visitAccessMember(AccessMember exp) {
1113+
void visitAccessMember(syntax.AccessMember exp) {
11141114
ast = new FieldReadAST(visit(exp.object), exp.name);
11151115
}
1116-
visitBinary(Binary exp) {
1116+
void visitBinary(syntax.Binary exp) {
11171117
ast = new PureFunctionAST(exp.operation,
11181118
_operationToFunction(exp.operation),
11191119
[visit(exp.left), visit(exp.right)]);
11201120
}
1121-
void visitPrefix(Prefix exp) {
1121+
void visitPrefix(syntax.Prefix exp) {
11221122
ast = new PureFunctionAST(exp.operation,
11231123
_operationToFunction(exp.operation),
11241124
[visit(exp.expression)]);
11251125
}
1126-
void visitConditional(Conditional exp) {
1126+
void visitConditional(syntax.Conditional exp) {
11271127
ast = new PureFunctionAST('?:', _operation_ternary,
11281128
[visit(exp.condition), visit(exp.yes),
11291129
visit(exp.no)]);
11301130
}
1131-
void visitAccessKeyed(AccessKeyed exp) {
1131+
void visitAccessKeyed(syntax.AccessKeyed exp) {
11321132
ast = new ClosureAST('[]', _operation_bracket,
11331133
[visit(exp.object), visit(exp.key)]);
11341134
}
1135-
void visitLiteralPrimitive(LiteralPrimitive exp) {
1135+
void visitLiteralPrimitive(syntax.LiteralPrimitive exp) {
11361136
ast = new ConstantAST(exp.value);
11371137
}
1138-
void visitLiteralString(LiteralString exp) {
1138+
void visitLiteralString(syntax.LiteralString exp) {
11391139
ast = new ConstantAST(exp.value);
11401140
}
1141-
void visitLiteralArray(LiteralArray exp) {
1141+
void visitLiteralArray(syntax.LiteralArray exp) {
11421142
List<AST> items = _toAst(exp.elements);
11431143
ast = new PureFunctionAST('[${items.join(', ')}]', new ArrayFn(), items);
11441144
}
11451145

1146-
void visitLiteralObject(LiteralObject exp) {
1146+
void visitLiteralObject(syntax.LiteralObject exp) {
11471147
List<String> keys = exp.keys;
11481148
List<AST> values = _toAst(exp.values);
11491149
assert(keys.length == values.length);
@@ -1154,31 +1154,31 @@ class ExpressionVisitor implements Visitor {
11541154
ast = new PureFunctionAST('{${kv.join(', ')}}', new MapFn(keys), values);
11551155
}
11561156

1157-
void visitFilter(Filter exp) {
1157+
void visitFormatter(syntax.Formatter exp) {
11581158
if (formatters == null) {
11591159
throw new Exception("No formatters have been registered");
11601160
}
1161-
Function filterFunction = formatters(exp.name);
1161+
Function formatterFunction = formatters(exp.name);
11621162
List<AST> args = [visitCollection(exp.expression)];
11631163
args.addAll(_toAst(exp.arguments).map((ast) => new CollectionAST(ast)));
11641164
ast = new PureFunctionAST('|${exp.name}',
1165-
new _FilterWrapper(filterFunction, args.length), args);
1165+
new _FormatterWrapper(formatterFunction, args.length), args);
11661166
}
11671167

11681168
// TODO(misko): this is a corner case. Choosing not to implement for now.
1169-
void visitCallFunction(CallFunction exp) {
1169+
void visitCallFunction(syntax.CallFunction exp) {
11701170
_notSupported("function's returing functions");
11711171
}
1172-
void visitAssign(Assign exp) {
1172+
void visitAssign(syntax.Assign exp) {
11731173
_notSupported('assignement');
11741174
}
1175-
void visitLiteral(Literal exp) {
1175+
void visitLiteral(syntax.Literal exp) {
11761176
_notSupported('literal');
11771177
}
1178-
void visitExpression(Expression exp) {
1178+
void visitExpression(syntax.Expression exp) {
11791179
_notSupported('?');
11801180
}
1181-
void visitChain(Chain exp) {
1181+
void visitChain(syntax.Chain exp) {
11821182
_notSupported(';');
11831183
}
11841184

@@ -1249,11 +1249,11 @@ class MapFn extends FunctionApply {
12491249
}
12501250
}
12511251

1252-
class _FilterWrapper extends FunctionApply {
1253-
final Function filterFn;
1252+
class _FormatterWrapper extends FunctionApply {
1253+
final Function formatterFn;
12541254
final List args;
12551255
final List<Watch> argsWatches;
1256-
_FilterWrapper(this.filterFn, length):
1256+
_FormatterWrapper(this.formatterFn, length):
12571257
args = new List(length),
12581258
argsWatches = new List(length);
12591259

@@ -1271,7 +1271,7 @@ class _FilterWrapper extends FunctionApply {
12711271
}
12721272
}
12731273
}
1274-
var value = Function.apply(filterFn, args);
1274+
var value = Function.apply(formatterFn, args);
12751275
if (value is Iterable) {
12761276
// Since formatters are pure we can guarantee that this well never change.
12771277
// By wrapping in UnmodifiableListView we can hint to the dirty checker

lib/core_dom/common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DirectiveRef {
3535
* Creates a child injector that allows loading new directives, formatters and
3636
* services from the provided modules.
3737
*/
38-
Injector forceNewDirectivesAndFilters(Injector injector, List<Module> modules) {
38+
Injector forceNewDirectivesAndFormatters(Injector injector, List<Module> modules) {
3939
modules.add(new Module()
4040
..factory(Scope, (i) {
4141
var scope = i.parent.get(Scope);

lib/directive/ng_repeat.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ part of angular.directive;
3535
* specified the ng-repeat associates elements by identity in the collection.
3636
* It is an error to have more than one tracking function to resolve to the
3737
* same key. (This would mean that two distinct objects are mapped to the same
38-
* DOM element, which is not possible.) Filters should be applied to the
38+
* DOM element, which is not possible.) Formatters should be applied to the
3939
* expression, before specifying a tracking expression.
4040
*
4141
* For example: `item in items` is equivalent to `item in items track by

lib/routing/ng_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class NgView implements DetachAware, RouteProvider {
116116

117117
var viewInjector = modules == null ?
118118
_injector :
119-
forceNewDirectivesAndFilters(_injector, modules);
119+
forceNewDirectivesAndFormatters(_injector, modules);
120120

121121
var newDirectives = viewInjector.get(DirectiveMap);
122122
var viewFuture = viewDef.templateHtml != null ?

0 commit comments

Comments
 (0)