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

Commit

Permalink
fix(transformers): fix accidental breakage due to library rename. Add…
Browse files Browse the repository at this point in the history
…ed tests.
  • Loading branch information
mhevery committed Apr 2, 2014
1 parent 2b75836 commit 88593ee
Show file tree
Hide file tree
Showing 40 changed files with 285 additions and 188 deletions.
28 changes: 16 additions & 12 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ packages:
path: ".."
relative: true
source: path
version: "0.9.8"
version: "0.9.10"
args:
description: args
source: hosted
version: "0.10.0+1"
version: "0.10.0+2"
barback:
description: barback
source: hosted
version: "0.11.1"
browser:
description: browser
source: hosted
version: "0.9.1"
version: "0.10.0+1"
code_transformers:
description: code_transformers
source: hosted
version: "0.1.0"
version: "0.1.1"
collection:
description: collection
source: hosted
Expand All @@ -45,27 +45,31 @@ packages:
intl:
description: intl
source: hosted
version: "0.8.10+4"
version: "0.9.8"
logging:
description: logging
source: hosted
version: "0.9.1+1"
meta:
description: meta
matcher:
description: matcher
source: hosted
version: "0.8.8"
version: "0.10.0"
mock:
description: mock
source: hosted
version: "0.10.0"
path:
description: path
source: hosted
version: "1.0.0"
version: "1.1.0"
perf_api:
description: perf_api
source: hosted
version: "0.0.8"
route_hierarchical:
description: route_hierarchical
source: hosted
version: "0.4.14"
version: "0.4.15"
shadow_dom:
description: shadow_dom
source: hosted
Expand All @@ -77,11 +81,11 @@ packages:
stack_trace:
description: stack_trace
source: hosted
version: "0.9.2"
version: "0.9.3"
unittest:
description: unittest
source: hosted
version: "0.10.0"
version: "0.10.1+2"
utf:
description: utf
source: hosted
Expand Down
2 changes: 1 addition & 1 deletion example/web/bouncing_balls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class MyModule extends Module {
MyModule() {
type(BounceController);
type(BallPositionDirective);
factory(ScopeStatsConfig, (i) => new ScopeStatsConfig(emit: false));
factory(ScopeStatsConfig, (i) => new ScopeStatsConfig());
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/angular_dynamic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library angular.app.dynamic;

import 'package:di/dynamic_injector.dart';
import "package:angular/angular.dart";
import "package:angular/core/module_internal.dart";
import 'package:angular/core/registry.dart';
import "package:angular/core/parser/parser.dart" show ClosureMap;
import 'package:angular/change_detection/change_detection.dart';
import 'package:angular/change_detection/dirty_checking_change_detector_dynamic.dart';
Expand Down
44 changes: 5 additions & 39 deletions lib/angular_static.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ library angular.app.static;
import 'package:di/static_injector.dart';
import 'package:di/di.dart' show TypeFactory, Injector;
import 'package:angular/bootstrap.dart';
import 'package:angular/core/module_internal.dart';
import 'package:angular/core/registry.dart';
import 'package:angular/core/parser/parser.dart';
import 'package:angular/core/parser/parser_static.dart';
import 'package:angular/core/parser/dynamic_parser.dart';
import 'package:angular/core/registry_static.dart';
import 'package:angular/change_detection/change_detection.dart';
import 'package:angular/change_detection/dirty_checking_change_detector_static.dart';

export 'package:angular/core/parser/parser_static.dart' show
StaticClosureMap;

class _StaticApplication extends Application {
final Map<Type, TypeFactory> typeFactories;

Expand All @@ -29,44 +33,6 @@ class _StaticApplication extends Application {
new StaticInjector(modules: modules, typeFactories: typeFactories);
}

class StaticClosureMap extends ClosureMap {
final Map<String, Getter> getters;
final Map<String, Setter> setters;
final Map<String, Symbol> symbols;

StaticClosureMap(this.getters, this.setters, this.symbols);

Getter lookupGetter(String name) {
Getter getter = getters[name];
if (getter == null) throw "No getter for '$name'.";
return getter;
}

Setter lookupSetter(String name) {
Setter setter = setters[name];
if (setter == null) throw "No setter for '$name'.";
return setter;
}

MethodClosure lookupFunction(String name, CallArguments arguments) {
var fn = lookupGetter(name);
return (o, posArgs, namedArgs) {
var sNamedArgs = {};
namedArgs.forEach((name, value) => sNamedArgs[symbols[name]] = value);
if (o is Map) {
var fn = o[name];
if (fn is Function) {
return Function.apply(fn, posArgs, sNamedArgs);
} else {
throw "Property '$name' is not of type function.";
}
} else {
return Function.apply(fn(o), posArgs, sNamedArgs);
}
};
}
}

Application staticApplication(
Map<Type, TypeFactory> typeFactories,
Map<Type, Object> metadata,
Expand Down
1 change: 1 addition & 0 deletions lib/animate/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ library angular.animate;
import 'dart:async';
import 'dart:html' as dom;

import 'package:angular/core/annotation.dart';
import 'package:angular/core/module_internal.dart';
import 'package:angular/core_dom/module_internal.dart';
import 'package:angular/core_dom/dom_util.dart' as util;
Expand Down
1 change: 1 addition & 0 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:di/di.dart';
import 'package:angular/angular.dart';
import 'package:angular/perf/module.dart';
import 'package:angular/core/module_internal.dart';
import 'package:angular/core/registry.dart';
import 'package:angular/core_dom/module_internal.dart';
import 'package:angular/directive/module.dart';
import 'package:angular/filter/module.dart';
Expand Down
46 changes: 45 additions & 1 deletion lib/core/directive.dart → lib/core/annotation.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
part of angular.core_internal;
library angular.core.annotation;

import "package:di/di.dart" show Visibility, Injector;

/**
* An annotation when applied to a class indicates that the class (service) will
* be instantiated by di injector.
*/
class NgInjectableService {
const NgInjectableService();
}

abstract class NgAnnotation {
/**
Expand Down Expand Up @@ -469,3 +479,37 @@ abstract class NgDetachAware {
void detach();
}


/**
* Use @[NgFilter] annotation to register a new filter. A filter is a class
* with a [call] method (a callable function).
*
* Usage:
*
* // Declaration
* @NgFilter(name:'myFilter')
* class MyFilter {
* call(valueToFilter, optArg1, optArg2) {
* return ...;
* }
* }
*
*
* // Registration
* var module = ...;
* module.type(MyFilter);
*
*
* <!-- Usage -->
* <span>{{something | myFilter:arg1:arg2}}</span>
*/
class NgFilter {
final String name;

const NgFilter({this.name});

int get hashCode => name.hashCode;
bool operator==(other) => name == other.name;

toString() => 'NgFilter: $name';
}
33 changes: 0 additions & 33 deletions lib/core/filter.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
part of angular.core_internal;

/**
* Use @[NgFilter] annotation to register a new filter. A filter is a class
* with a [call] method (a callable function).
*
* Usage:
*
* // Declaration
* @NgFilter(name:'myFilter')
* class MyFilter {
* call(valueToFilter, optArg1, optArg2) {
* return ...;
* }
* }
*
*
* // Registration
* var module = ...;
* module.type(MyFilter);
*
*
* <!-- Usage -->
* <span>{{something | myFilter:arg1:arg2}}</span>
*/
class NgFilter {
final String name;

const NgFilter({this.name});

int get hashCode => name.hashCode;
bool operator==(other) => name == other.name;

toString() => 'NgFilter: $name';
}

/**
* Registry of filters at runtime.
Expand Down
26 changes: 14 additions & 12 deletions lib/core/module.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
library angular.core;

export "package:angular/core/service.dart";

export "package:angular/core/annotation.dart" show
NgAttachAware,
NgAttr,
NgComponent,
NgController,
NgDetachAware,
NgDirective,
NgFilter,
NgInjectableService,
NgOneWay,
NgOneWayOneTime,
NgTwoWay;

export "package:angular/core_dom/module_internal.dart" show
Animation,
AnimationResult,
Expand Down Expand Up @@ -32,18 +45,7 @@ export "package:angular/core/module_internal.dart" show
CacheStats,
ExceptionHandler,
Interpolate,
NgAttachAware,
NgAttr,
NgCallback,
NgComponent,
NgController,
NgDetachAware,
NgDirective,
NgFilter,
NgInjectableService,
NgOneWay,
NgOneWayOneTime,
NgTwoWay,
NgZone,
PrototypeMap,
RootScope,
Expand Down
6 changes: 2 additions & 4 deletions lib/core/module_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ import 'package:angular/core/parser/parser.dart';
import 'package:angular/core/parser/lexer.dart';
import 'package:angular/utils.dart';

import 'package:angular/core/service.dart';
export 'package:angular/core/service.dart';
import 'package:angular/core/annotation.dart';

import 'package:angular/change_detection/watch_group.dart';
export 'package:angular/change_detection/watch_group.dart';
import 'package:angular/change_detection/change_detection.dart';
import 'package:angular/change_detection/dirty_checking_change_detector.dart';
import 'package:angular/core/parser/utils.dart';
import 'package:angular/core/parser/syntax.dart';
import 'package:angular/core/registry.dart';

part "cache.dart";
part "directive.dart";
part "exception_handler.dart";
part "filter.dart";
part "interpolate.dart";
part "registry.dart";
part "scope.dart";
part "zone.dart";

Expand Down
4 changes: 3 additions & 1 deletion lib/core/parser/dynamic_parser.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library angular.core.parser.dynamic_parser;

import 'package:angular/core/annotation.dart';
import 'package:angular/core/module_internal.dart' show FilterMap, NgInjectableService;

import 'package:angular/core/parser/parser.dart';
Expand All @@ -14,6 +15,7 @@ import 'package:angular/utils.dart';
abstract class ClosureMap {
Getter lookupGetter(String name);
Setter lookupSetter(String name);
Symbol lookupSymbol(String name);
MethodClosure lookupFunction(String name, CallArguments arguments);
}

Expand Down Expand Up @@ -84,7 +86,7 @@ class DynamicParserBackend extends ParserBackend {

Expression newAccessKeyed(object, key) => new AccessKeyed(object, key);
Expression newCallFunction(function, arguments) =>
new CallFunction(function, arguments);
new CallFunction(function, _closures, arguments);

Expression newPrefixNot(expression) => new PrefixNot(expression);

Expand Down
Loading

0 comments on commit 88593ee

Please sign in to comment.