refactor(core): move DI bindings of compiler into core/compiler/compiler.ts

Closes #4470
This commit is contained in:
Tobias Bosch 2015-10-02 11:10:08 -07:00
parent 13161ae5aa
commit 4342a1eb7b
5 changed files with 13 additions and 35 deletions

View File

@ -15,6 +15,7 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/core/facade/async'; import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/core/facade/async';
import {XHR} from 'angular2/src/core/compiler/xhr'; import {XHR} from 'angular2/src/core/compiler/xhr';
import {XHRImpl} from 'angular2/src/core/compiler/xhr_impl'; import {XHRImpl} from 'angular2/src/core/compiler/xhr_impl';
import { import {
EventManager, EventManager,
DomEventsPlugin, DomEventsPlugin,
@ -22,8 +23,6 @@ import {
} from 'angular2/src/core/render/dom/events/event_manager'; } from 'angular2/src/core/render/dom/events/event_manager';
import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events'; import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures'; import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures';
import {AppRootUrl} from 'angular2/src/core/compiler/app_root_url';
import {AnchorBasedAppRootUrl} from 'angular2/src/core/compiler/anchor_based_app_root_url';
import { import {
ComponentRef, ComponentRef,
DynamicComponentLoader DynamicComponentLoader
@ -31,11 +30,6 @@ import {
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability'; import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
import {Renderer} from 'angular2/src/core/render/api'; import {Renderer} from 'angular2/src/core/render/api';
import {DomRenderer, DOCUMENT} from 'angular2/src/core/render/render'; import {DomRenderer, DOCUMENT} from 'angular2/src/core/render/render';
import {APP_ID_RANDOM_BINDING} from 'angular2/src/core/application_tokens';
import {ElementSchemaRegistry} from 'angular2/src/core/compiler/schema/element_schema_registry';
import {
DomElementSchemaRegistry
} from 'angular2/src/core/compiler/schema/dom_element_schema_registry';
import { import {
SharedStylesHost, SharedStylesHost,
DomSharedStylesHost DomSharedStylesHost
@ -63,15 +57,11 @@ export function applicationDomBindings(): Array<Type | Binding | any[]> {
new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}), new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
DomRenderer, DomRenderer,
bind(Renderer).toAlias(DomRenderer), bind(Renderer).toAlias(DomRenderer),
APP_ID_RANDOM_BINDING,
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
DomSharedStylesHost, DomSharedStylesHost,
bind(SharedStylesHost).toAlias(DomSharedStylesHost), bind(SharedStylesHost).toAlias(DomSharedStylesHost),
EXCEPTION_BINDING, EXCEPTION_BINDING,
bind(XHR).toValue(new XHRImpl()), bind(XHR).toValue(new XHRImpl()),
Testability, Testability,
AnchorBasedAppRootUrl,
bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
BrowserDetails, BrowserDetails,
AnimationBuilder, AnimationBuilder,
FORM_BINDINGS FORM_BINDINGS

View File

@ -23,8 +23,6 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {internalView} from 'angular2/src/core/linker/view_ref'; import {internalView} from 'angular2/src/core/linker/view_ref';
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
import { import {
Parser,
Lexer,
IterableDiffers, IterableDiffers,
defaultIterableDiffers, defaultIterableDiffers,
KeyValueDiffers, KeyValueDiffers,
@ -39,7 +37,6 @@ import {DEFAULT_PIPES} from 'angular2/src/core/pipes';
import {ViewResolver} from './linker/view_resolver'; import {ViewResolver} from './linker/view_resolver';
import {DirectiveResolver} from './linker/directive_resolver'; import {DirectiveResolver} from './linker/directive_resolver';
import {PipeResolver} from './linker/pipe_resolver'; import {PipeResolver} from './linker/pipe_resolver';
import {UrlResolver} from 'angular2/src/core/compiler/url_resolver';
import {Compiler} from 'angular2/src/core/linker/compiler'; import {Compiler} from 'angular2/src/core/linker/compiler';
/** /**
@ -99,10 +96,7 @@ export function applicationCommonBindings(): Array<Type | Binding | any[]> {
bind(IterableDiffers).toValue(defaultIterableDiffers), bind(IterableDiffers).toValue(defaultIterableDiffers),
bind(KeyValueDiffers).toValue(defaultKeyValueDiffers), bind(KeyValueDiffers).toValue(defaultKeyValueDiffers),
DirectiveResolver, DirectiveResolver,
UrlResolver,
PipeResolver, PipeResolver,
Parser,
Lexer,
DynamicComponentLoader, DynamicComponentLoader,
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()), bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
[ExceptionHandler]), [ExceptionHandler]),

View File

@ -7,7 +7,7 @@ export 'dart:core' show List;
export 'package:angular2/src/core/change_detection/abstract_change_detector.dart' export 'package:angular2/src/core/change_detection/abstract_change_detector.dart'
show AbstractChangeDetector; show AbstractChangeDetector;
export 'package:angular2/src/core/change_detection/change_detection.dart' export 'package:angular2/src/core/change_detection/change_detection.dart'
show preGeneratedProtoDetectors, ChangeDetectionStrategy; show ChangeDetectionStrategy;
export 'package:angular2/src/core/change_detection/directive_record.dart' export 'package:angular2/src/core/change_detection/directive_record.dart'
show DirectiveIndex, DirectiveRecord; show DirectiveIndex, DirectiveRecord;
export 'package:angular2/src/core/change_detection/interfaces.dart' export 'package:angular2/src/core/change_detection/interfaces.dart'

View File

@ -23,9 +23,15 @@ import {ElementSchemaRegistry} from 'angular2/src/core/compiler/schema/element_s
import { import {
DomElementSchemaRegistry DomElementSchemaRegistry
} from 'angular2/src/core/compiler/schema/dom_element_schema_registry'; } from 'angular2/src/core/compiler/schema/dom_element_schema_registry';
import {UrlResolver} from 'angular2/src/core/compiler/url_resolver';
import {AppRootUrl} from 'angular2/src/core/compiler/app_root_url';
import {AnchorBasedAppRootUrl} from 'angular2/src/core/compiler/anchor_based_app_root_url';
import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
export function compilerBindings(): Array<Type | Binding | any[]> { export function compilerBindings(): Array<Type | Binding | any[]> {
return [ return [
Lexer,
Parser,
HtmlParser, HtmlParser,
TemplateParser, TemplateParser,
TemplateNormalizer, TemplateNormalizer,
@ -40,6 +46,9 @@ export function compilerBindings(): Array<Type | Binding | any[]> {
RuntimeCompiler, RuntimeCompiler,
bind(Compiler).toAlias(RuntimeCompiler), bind(Compiler).toAlias(RuntimeCompiler),
DomElementSchemaRegistry, DomElementSchemaRegistry,
bind(ElementSchemaRegistry).toAlias(DomElementSchemaRegistry) bind(ElementSchemaRegistry).toAlias(DomElementSchemaRegistry),
AnchorBasedAppRootUrl,
bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
UrlResolver
]; ];
} }

View File

@ -6,8 +6,6 @@ import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock';
import {ProtoViewFactory} from 'angular2/src/core/linker/proto_view_factory'; import {ProtoViewFactory} from 'angular2/src/core/linker/proto_view_factory';
import {Reflector, reflector} from 'angular2/src/core/reflection/reflection'; import {Reflector, reflector} from 'angular2/src/core/reflection/reflection';
import { import {
Parser,
Lexer,
IterableDiffers, IterableDiffers,
defaultIterableDiffers, defaultIterableDiffers,
KeyValueDiffers, KeyValueDiffers,
@ -20,9 +18,6 @@ import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver';
import {PipeResolver} from 'angular2/src/core/linker/pipe_resolver'; import {PipeResolver} from 'angular2/src/core/linker/pipe_resolver';
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
import {XHR} from 'angular2/src/core/compiler/xhr'; import {XHR} from 'angular2/src/core/compiler/xhr';
import {UrlResolver} from 'angular2/src/core/compiler/url_resolver';
import {AppRootUrl} from 'angular2/src/core/compiler/app_root_url';
import {AnchorBasedAppRootUrl} from 'angular2/src/core/compiler/anchor_based_app_root_url';
import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
@ -58,11 +53,7 @@ import {
SharedStylesHost, SharedStylesHost,
DomSharedStylesHost DomSharedStylesHost
} from 'angular2/src/core/render/render'; } from 'angular2/src/core/render/render';
import {APP_ID} from 'angular2/src/core/application_tokens' import { ElementSchemaRegistry } import {APP_ID} from 'angular2/src/core/application_tokens';
from 'angular2/src/core/compiler/schema/element_schema_registry';
import {
DomElementSchemaRegistry
} from 'angular2/src/core/compiler/schema/dom_element_schema_registry';
import {Serializer} from "angular2/src/web_workers/shared/serializer"; import {Serializer} from "angular2/src/web_workers/shared/serializer";
import {Log} from './utils'; import {Log} from './utils';
import {compilerBindings} from 'angular2/src/core/compiler/compiler'; import {compilerBindings} from 'angular2/src/core/compiler/compiler';
@ -105,7 +96,6 @@ function _getAppBindings() {
DomRenderer, DomRenderer,
bind(Renderer).toAlias(DomRenderer), bind(Renderer).toAlias(DomRenderer),
bind(APP_ID).toValue('a'), bind(APP_ID).toValue('a'),
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
DomSharedStylesHost, DomSharedStylesHost,
bind(SharedStylesHost).toAlias(DomSharedStylesHost), bind(SharedStylesHost).toAlias(DomSharedStylesHost),
AppViewPool, AppViewPool,
@ -123,14 +113,9 @@ function _getAppBindings() {
Log, Log,
DynamicComponentLoader, DynamicComponentLoader,
PipeResolver, PipeResolver,
Parser,
Lexer,
bind(ExceptionHandler).toValue(new ExceptionHandler(DOM)), bind(ExceptionHandler).toValue(new ExceptionHandler(DOM)),
bind(LocationStrategy).toClass(MockLocationStrategy), bind(LocationStrategy).toClass(MockLocationStrategy),
bind(XHR).toClass(MockXHR), bind(XHR).toClass(MockXHR),
UrlResolver,
AnchorBasedAppRootUrl,
bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
TestComponentBuilder, TestComponentBuilder,
bind(NgZone).toClass(MockNgZone), bind(NgZone).toClass(MockNgZone),
bind(AnimationBuilder).toClass(MockAnimationBuilder), bind(AnimationBuilder).toClass(MockAnimationBuilder),