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

Commit

Permalink
feat(di): introduced @NgInjectableService to make di codegen easier
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj committed Dec 2, 2013
1 parent ea769d6 commit 54328d7
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/core/directive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ abstract class NgDetachAware {
void detach();
}

@NgInjectableService()
class DirectiveMap extends AnnotationMap<NgAnnotation> {
DirectiveMap(Injector injector, MetadataExtractor metadataExtractor,
FieldMetadataExtractor fieldMetadataExtractor)
Expand Down Expand Up @@ -445,6 +446,7 @@ class DirectiveMap extends AnnotationMap<NgAnnotation> {
}
}

@NgInjectableService()
class FieldMetadataExtractor {
List<TypeMirror> _fieldAnnotations = [reflectType(NgAttr),
reflectType(NgOneWay), reflectType(NgOneWayOneTime),
Expand Down
1 change: 1 addition & 0 deletions lib/core/exception_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ part of angular.core;
* In your application it is expected that this service is overridden with
* your implementation which can store the exception for later processing.
*/
@NgInjectableService()
class ExceptionHandler {

/**
Expand Down
1 change: 1 addition & 0 deletions lib/core/filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class NgFilter {
/**
* Registry of filters at runtime.
*/
@NgInjectableService()
class FilterMap extends AnnotationMap<NgFilter> {
Injector _injector;
FilterMap(Injector injector, MetadataExtractor extractMetadata) : super(injector, extractMetadata) {
Expand Down
1 change: 1 addition & 0 deletions lib/core/interpolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Interpolation {
* var exp = $interpolate('Hello {{name}}!');
* expect(exp({name:'Angular'}).toEqual('Hello Angular!');
*/
@NgInjectableService()
class Interpolate {
final Parser _parse;

Expand Down
2 changes: 2 additions & 0 deletions lib/core/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:perf_api/perf_api.dart';
import 'package:angular/core/parser/parser_library.dart';
import 'package:angular/utils.dart';

import 'service.dart';
export 'service.dart';

part "cache.dart";
part "directive.dart";
Expand Down
2 changes: 2 additions & 0 deletions lib/core/parser/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Expression implements ParserAST {
get assignable => assign != null;
}

@NgInjectableService()
class GetterSetter {
static stripTrailingNulls(List l) {
while (l.length > 0 && l.last == null) {
Expand Down Expand Up @@ -87,6 +88,7 @@ class GetterSetter {

var undefined_ = const Symbol("UNDEFINED");

@NgInjectableService()
class ParserBackend {
GetterSetter _getterSetter;
FilterMap _filters;
Expand Down
1 change: 1 addition & 0 deletions lib/core/parser/lexer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
part of angular.core.parser;

@NgInjectableService()
class Lexer {
static const String QUOTES = "\"'";
static const String DOT = ".";
Expand Down
1 change: 1 addition & 0 deletions lib/core/parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Map<String, Operator> OPERATORS = {
'?': (s, l, c, t, f) => toBool(c.eval(s, l)) ? t.eval(s, l) : f.eval(s, l),
};

@NgInjectableService()
class DynamicParser implements Parser {
final Lexer _lexer;
final ParserBackend _b;
Expand Down
1 change: 1 addition & 0 deletions lib/core/parser/static_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class StaticParserFunctions {
Map<String, dynamic> functions;
}

@NgInjectableService()
class StaticParser implements Parser {
Map<String, dynamic> _functions;
Parser _fallbackParser;
Expand Down
1 change: 1 addition & 0 deletions lib/core/registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abstract class AnnotationMap<K> {
}
}

@NgInjectableService()
class MetadataExtractor {

Iterable call(Type type) {
Expand Down
2 changes: 2 additions & 0 deletions lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ScopeEvent {
* triggers watch A. If the system does not stabilize in TTL iteration then
* an digest is stop an an exception is thrown.
*/
@NgInjectableService()
class ScopeDigestTTL {
final num ttl;
ScopeDigestTTL(): ttl = 5;
Expand All @@ -37,6 +38,7 @@ class ScopeDigestTTL {
* data-binding.
*/
@proxy
@NgInjectableService()
class Scope implements Map {
final ExceptionHandler _exceptionHandler;
final Parser _parser;
Expand Down
9 changes: 9 additions & 0 deletions lib/core/service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library angular.core.service;

/**
* An annotation when applied to a class indicates that the class (service) will
* be instantiated by di injector.
*/
class NgInjectableService {
const NgInjectableService();
}
2 changes: 1 addition & 1 deletion lib/core_dom/block_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class BlockFactory {
* It can be used synchronously if HTML is known or asynchronously if the
* template HTML needs to be looked up from the URL.
*/

@NgInjectableService()
class BlockCache {
// _blockFactoryCache is unbounded
Cache<String, BlockFactory> _blockFactoryCache =
Expand Down
1 change: 1 addition & 0 deletions lib/core_dom/compiler.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
part of angular.core.dom;

@NgInjectableService()
class Compiler {
final DirectiveMap directives;
final Profiler _perf;
Expand Down
1 change: 1 addition & 0 deletions lib/core_dom/cookies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ part of angular.core.dom;
*
* NOTE the Cookies service is not yet implemented.
*/
@NgInjectableService()
class BrowserCookies {
dom.Document _document;

Expand Down
7 changes: 7 additions & 0 deletions lib/core_dom/http.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
part of angular.core.dom;

@NgInjectableService()
class UrlRewriter {
String call(url) => url;
}
Expand All @@ -13,6 +14,7 @@ class UrlRewriter {
* During testing this implementation is swapped with [MockHttpBackend] which
* can be trained with responses.
*/
@NgInjectableService()
class HttpBackend {
/**
* Wrapper around dart:html's [HttpRequest.request]
Expand All @@ -36,6 +38,7 @@ class HttpBackend {
}
}

@NgInjectableService()
class LocationWrapper {
get location => dom.window.location;
}
Expand Down Expand Up @@ -103,6 +106,7 @@ class DefaultTransformDataHttpInterceptor implements HttpInterceptor {
/**
* A list of [HttpInterceptor]s.
*/
@NgInjectableService()
class HttpInterceptors {
List<HttpInterceptor> _interceptors = [new DefaultTransformDataHttpInterceptor()];

Expand Down Expand Up @@ -256,6 +260,7 @@ class HttpResponse {
/**
* Default header configuration.
*/
@NgInjectableService()
class HttpDefaultHeaders {
static String _defaultContentType = 'application/json;charset=utf-8';
Map _headers = {
Expand Down Expand Up @@ -311,6 +316,7 @@ class HttpDefaultHeaders {
* The default implementation provides headers which the
* Angular team believes to be useful.
*/
@NgInjectableService()
class HttpDefaults {
/**
* The [HttpDefaultHeaders] object used by [Http] to add default headers
Expand Down Expand Up @@ -397,6 +403,7 @@ class HttpDefaults {
*
* NOTE: < not yet documented >
*/
@NgInjectableService()
class Http {
Map<String, async.Future<HttpResponse>> _pendingRequests = <String, async.Future<HttpResponse>>{};
BrowserCookies _cookies;
Expand Down
1 change: 1 addition & 0 deletions lib/core_dom/tree_sanitizer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
part of angular.core.dom;

@NgInjectableService()
class NullTreeSanitizer implements dom.NodeTreeSanitizer {
void sanitizeTree(dom.Node node) {}
}
1 change: 1 addition & 0 deletions lib/routing/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class NgRoutingModule extends Module {
* "http://host:port/path#/foo/bar?baz=qux". Everything after hash (#) is used
* by the router.
*/
@NgInjectableService()
class NgRoutingUsePushState {
final bool usePushState;
NgRoutingUsePushState(): usePushState = true;
Expand Down
1 change: 1 addition & 0 deletions lib/routing/routing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract class RouteInitializer {
* A singleton helper service that handles routing initialization, global
* events and view registries.
*/
@NgInjectableService()
class NgRoutingHelper {
final Router router;
List<NgViewDirective> portals = <NgViewDirective>[];
Expand Down

0 comments on commit 54328d7

Please sign in to comment.