feat(di): Add the `@Injectable` annotation to `Compiler`

Mark `Compiler` and its dependencies as available to the `Injector`.
This commit is contained in:
Tim Blasi 2015-03-16 14:44:14 -07:00 committed by Misko Hevery
parent b656f63430
commit 57723e1354
18 changed files with 40 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {List, ListWrapper, SetWrapper} from "angular2/src/facade/collection";
import {int, NumberWrapper, StringJoiner, StringWrapper} from "angular2/src/facade/lang";
@ -8,6 +9,7 @@ export const TOKEN_TYPE_STRING = 4;
export const TOKEN_TYPE_OPERATOR = 5;
export const TOKEN_TYPE_NUMBER = 6;
@Injectable()
export class Lexer {
text:string;
tokenize(text:string):List {

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {int, isBlank, isPresent, BaseException, StringWrapper, RegExpWrapper} from 'angular2/src/facade/lang';
import {ListWrapper, List} from 'angular2/src/facade/collection';
import {Lexer, EOF, Token, $PERIOD, $COLON, $SEMICOLON, $LBRACKET, $RBRACKET,
@ -32,6 +33,7 @@ var _implicitReceiver = new ImplicitReceiver();
var INTERPOLATION_REGEXP = RegExpWrapper.create('\\{\\{(.*?)\\}\\}');
var QUOTE_REGEXP = RegExpWrapper.create("'");
@Injectable()
export class Parser {
_lexer:Lexer;
_reflector:Reflector;

View File

@ -1,5 +1,6 @@
import {ABSTRACT, CONST, normalizeBlank, isPresent} from 'angular2/src/facade/lang';
import {ListWrapper, List} from 'angular2/src/facade/collection';
import {Injectable} from 'angular2/di';
// type StringMap = {[idx: string]: string};
@ -10,7 +11,7 @@ import {ListWrapper, List} from 'angular2/src/facade/collection';
* @publicModule angular2/angular2
*/
@ABSTRACT()
export class Directive {
export class Directive extends Injectable {
/**
* The CSS selector that triggers the instantiation of a directive.
*
@ -189,6 +190,7 @@ export class Directive {
lifecycle:List
}={})
{
super();
this.selector = selector;
this.bind = bind;
this.events = events;

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {Type, isBlank, isPresent, BaseException, normalizeBlank, stringify} from 'angular2/src/facade/lang';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection';
@ -23,6 +24,7 @@ import {CssProcessor} from './css_processor';
* Used to prevent duplicate work and resolve cyclic dependencies.
* @publicModule angular2/angular2
*/
@Injectable()
export class CompilerCache {
_cache:Map;
constructor() {
@ -49,6 +51,7 @@ export class CompilerCache {
* the CompilePipeline and the CompileSteps.
* @publicModule angular2/angular2
*/
@Injectable()
export class Compiler {
_reader: DirectiveMetadataReader;
_parser:Parser;

View File

@ -1,6 +1,8 @@
import {Injectable} from 'angular2/di';
import {Type, isPresent} from 'angular2/src/facade/lang';
import {Map, MapWrapper} from 'angular2/src/facade/collection';
@Injectable()
export class ComponentUrlMapper {
// Returns the base URL to the component source file.
// The returned URL could be:

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {isPresent} from 'angular2/src/facade/lang';
@ -15,6 +16,7 @@ import {DirectiveMetadata} from './directive_metadata';
* - Apply any given transformers,
* - Apply the shadow DOM strategy style step.
*/
@Injectable()
export class CssProcessor {
_transformers: List<CssTransformer>;

View File

@ -1,8 +1,10 @@
import {Injectable} from 'angular2/di';
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
import {Directive} from '../annotations/annotations';
import {DirectiveMetadata} from './directive_metadata';
import {reflector} from 'angular2/src/reflection/reflection';
@Injectable()
export class DirectiveMetadataReader {
read(type:Type):DirectiveMetadata {
var annotations = reflector.annotations(type);

View File

@ -1,4 +1,5 @@
import * as ldModule from './light_dom';
import {Inject, Injectable} from 'angular2/di';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {isPresent} from 'angular2/src/facade/lang';
import {List, ListWrapper} from 'angular2/src/facade/collection';
@ -13,6 +14,7 @@ class ContentStrategy {
* It is used when the content tag is not a direct child of another component,
* and thus does not affect redistribution.
*/
@Injectable()
class RenderedContent extends ContentStrategy {
beginScript;
endScript;

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {Type, isBlank, isPresent, int, StringWrapper, assertionsEnabled} from 'angular2/src/facade/lang';
import {List, ListWrapper, MapWrapper, Map} from 'angular2/src/facade/collection';
import {PromiseWrapper} from 'angular2/src/facade/async';
@ -77,6 +78,7 @@ export class ShadowDomStrategy {
* - styles are **not** scoped to their component and will apply to the whole document,
* - you can **not** use shadow DOM specific selectors in the styles
*/
@Injectable()
export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy {
_styleUrlResolver: StyleUrlResolver;
_styleHost;
@ -118,6 +120,7 @@ export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy {
* - a common subset of shadow DOM selectors are supported,
* - see `ShadowCss` for more information and limitations.
*/
@Injectable()
export class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomStrategy {
_styleInliner: StyleInliner;
@ -148,6 +151,7 @@ export class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomSt
* The templates for the component are inserted in a Shadow Root created on the component element.
* Hence they are strictly isolated.
*/
@Injectable()
export class NativeShadowDomStrategy extends ShadowDomStrategy {
_styleUrlResolver: StyleUrlResolver;

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {XHR} from 'angular2/src/core/compiler/xhr/xhr';
import {StyleUrlResolver} from 'angular2/src/core/compiler/style_url_resolver';
import {UrlResolver} from 'angular2/src/core/compiler/url_resolver';
@ -21,6 +22,7 @@ import {
*
* When an @import rules is inlined, it's url are rewritten.
*/
@Injectable()
export class StyleInliner {
_xhr: XHR;
_urlResolver: UrlResolver;

View File

@ -1,12 +1,14 @@
// Some of the code comes from WebComponents.JS
// https://github.com/webcomponents/webcomponentsjs/blob/master/src/HTMLImports/path.js
import {Injectable} from 'angular2/di';
import {RegExp, RegExpWrapper, StringWrapper} from 'angular2/src/facade/lang';
import {UrlResolver} from './url_resolver';
/**
* Rewrites URLs by resolving '@import' and 'url()' URLs from the given base URL.
*/
@Injectable()
export class StyleUrlResolver {
_resolver: UrlResolver;

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {isBlank, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
import {Map, MapWrapper, StringMapWrapper, StringMap} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/dom/dom_adapter';
@ -12,6 +13,7 @@ import {UrlResolver} from './url_resolver';
* Strategy to load component templates.
* @publicModule angular2/angular2
*/
@Injectable()
export class TemplateLoader {
_xhr: XHR;
_htmlCache: StringMap;

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/di';
import {Template} from 'angular2/src/core/annotations/template';
import {Type, stringify, isBlank, BaseException} from 'angular2/src/facade/lang';
@ -6,6 +7,7 @@ import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection
import {reflector} from 'angular2/src/reflection/reflection';
@Injectable()
export class TemplateResolver {
_cache: Map;

View File

@ -1,6 +1,8 @@
import {Injectable} from 'angular2/di';
import {isPresent, isBlank, RegExpWrapper, BaseException} from 'angular2/src/facade/lang';
import {DOM} from 'angular2/src/dom/dom_adapter';
@Injectable()
export class UrlResolver {
static a;

View File

@ -1,7 +1,9 @@
import 'dart:async';
import 'dart:html';
import 'package:angular2/di.dart';
import './xhr.dart' show XHR;
@Injectable()
class XHRImpl extends XHR {
Future<String> get(String url) {
return HttpRequest.request(url).then(

View File

@ -1,6 +1,8 @@
import {Injectable} from 'angular2/di';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {XHR} from './xhr';
@Injectable()
export class XHRImpl extends XHR {
get(url: string): Promise<string> {
var completer = PromiseWrapper.completer();

View File

@ -1,6 +1,8 @@
import {Injectable} from 'angular2/di';
import {isPresent, print} from 'angular2/src/facade/lang';
import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection';
@Injectable()
export class ExceptionHandler {
call(error, stackTrace = null, reason = null) {
var longStackTrace = isListLikeIterable(stackTrace) ? ListWrapper.join(stackTrace, "\n\n") : stackTrace;

View File

@ -1,8 +1,10 @@
import {Injectable} from 'angular2/di';
import {ChangeDetector} from 'angular2/change_detection';
import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone';
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
import {isPresent} from 'angular2/src/facade/lang';
@Injectable()
export class LifeCycle {
_errorHandler;
_changeDetector:ChangeDetector;