From 4342a1eb7b1d9c6f44f49ab15f325ff326dbcaaa Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 2 Oct 2015 11:10:08 -0700 Subject: [PATCH] refactor(core): move DI bindings of compiler into core/compiler/compiler.ts Closes #4470 --- modules/angular2/src/core/application_common.ts | 12 +----------- modules/angular2/src/core/application_ref.ts | 6 ------ .../pregen_proto_change_detector.dart | 2 +- modules/angular2/src/core/compiler/compiler.ts | 11 ++++++++++- modules/angular2/src/test_lib/test_injector.ts | 17 +---------------- 5 files changed, 13 insertions(+), 35 deletions(-) diff --git a/modules/angular2/src/core/application_common.ts b/modules/angular2/src/core/application_common.ts index 0470b5ac56..5c6c29670d 100644 --- a/modules/angular2/src/core/application_common.ts +++ b/modules/angular2/src/core/application_common.ts @@ -15,6 +15,7 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/core/facade/async'; import {XHR} from 'angular2/src/core/compiler/xhr'; import {XHRImpl} from 'angular2/src/core/compiler/xhr_impl'; + import { EventManager, DomEventsPlugin, @@ -22,8 +23,6 @@ import { } from 'angular2/src/core/render/dom/events/event_manager'; import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events'; 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 { ComponentRef, DynamicComponentLoader @@ -31,11 +30,6 @@ import { import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability'; import {Renderer} from 'angular2/src/core/render/api'; 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 { SharedStylesHost, DomSharedStylesHost @@ -63,15 +57,11 @@ export function applicationDomBindings(): Array { new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}), DomRenderer, bind(Renderer).toAlias(DomRenderer), - APP_ID_RANDOM_BINDING, - bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()), DomSharedStylesHost, bind(SharedStylesHost).toAlias(DomSharedStylesHost), EXCEPTION_BINDING, bind(XHR).toValue(new XHRImpl()), Testability, - AnchorBasedAppRootUrl, - bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl), BrowserDetails, AnimationBuilder, FORM_BINDINGS diff --git a/modules/angular2/src/core/application_ref.ts b/modules/angular2/src/core/application_ref.ts index 938007cbb9..2f36f25266 100644 --- a/modules/angular2/src/core/application_ref.ts +++ b/modules/angular2/src/core/application_ref.ts @@ -23,8 +23,6 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {internalView} from 'angular2/src/core/linker/view_ref'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import { - Parser, - Lexer, IterableDiffers, defaultIterableDiffers, KeyValueDiffers, @@ -39,7 +37,6 @@ import {DEFAULT_PIPES} from 'angular2/src/core/pipes'; import {ViewResolver} from './linker/view_resolver'; import {DirectiveResolver} from './linker/directive_resolver'; import {PipeResolver} from './linker/pipe_resolver'; -import {UrlResolver} from 'angular2/src/core/compiler/url_resolver'; import {Compiler} from 'angular2/src/core/linker/compiler'; /** @@ -99,10 +96,7 @@ export function applicationCommonBindings(): Array { bind(IterableDiffers).toValue(defaultIterableDiffers), bind(KeyValueDiffers).toValue(defaultKeyValueDiffers), DirectiveResolver, - UrlResolver, PipeResolver, - Parser, - Lexer, DynamicComponentLoader, bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()), [ExceptionHandler]), diff --git a/modules/angular2/src/core/change_detection/pregen_proto_change_detector.dart b/modules/angular2/src/core/change_detection/pregen_proto_change_detector.dart index 6c2f0a7e82..76f1f24903 100644 --- a/modules/angular2/src/core/change_detection/pregen_proto_change_detector.dart +++ b/modules/angular2/src/core/change_detection/pregen_proto_change_detector.dart @@ -7,7 +7,7 @@ export 'dart:core' show List; export 'package:angular2/src/core/change_detection/abstract_change_detector.dart' show AbstractChangeDetector; 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' show DirectiveIndex, DirectiveRecord; export 'package:angular2/src/core/change_detection/interfaces.dart' diff --git a/modules/angular2/src/core/compiler/compiler.ts b/modules/angular2/src/core/compiler/compiler.ts index ed7493f4b0..b064af3af1 100644 --- a/modules/angular2/src/core/compiler/compiler.ts +++ b/modules/angular2/src/core/compiler/compiler.ts @@ -23,9 +23,15 @@ import {ElementSchemaRegistry} from 'angular2/src/core/compiler/schema/element_s import { DomElementSchemaRegistry } 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 { return [ + Lexer, + Parser, HtmlParser, TemplateParser, TemplateNormalizer, @@ -40,6 +46,9 @@ export function compilerBindings(): Array { RuntimeCompiler, bind(Compiler).toAlias(RuntimeCompiler), DomElementSchemaRegistry, - bind(ElementSchemaRegistry).toAlias(DomElementSchemaRegistry) + bind(ElementSchemaRegistry).toAlias(DomElementSchemaRegistry), + AnchorBasedAppRootUrl, + bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl), + UrlResolver ]; } diff --git a/modules/angular2/src/test_lib/test_injector.ts b/modules/angular2/src/test_lib/test_injector.ts index dd17722b6e..b980d2a092 100644 --- a/modules/angular2/src/test_lib/test_injector.ts +++ b/modules/angular2/src/test_lib/test_injector.ts @@ -6,8 +6,6 @@ import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock'; import {ProtoViewFactory} from 'angular2/src/core/linker/proto_view_factory'; import {Reflector, reflector} from 'angular2/src/core/reflection/reflection'; import { - Parser, - Lexer, IterableDiffers, defaultIterableDiffers, KeyValueDiffers, @@ -20,9 +18,6 @@ import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver'; import {PipeResolver} from 'angular2/src/core/linker/pipe_resolver'; import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; 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 {DOM} from 'angular2/src/core/dom/dom_adapter'; @@ -58,11 +53,7 @@ import { SharedStylesHost, DomSharedStylesHost } from 'angular2/src/core/render/render'; -import {APP_ID} 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 {APP_ID} from 'angular2/src/core/application_tokens'; import {Serializer} from "angular2/src/web_workers/shared/serializer"; import {Log} from './utils'; import {compilerBindings} from 'angular2/src/core/compiler/compiler'; @@ -105,7 +96,6 @@ function _getAppBindings() { DomRenderer, bind(Renderer).toAlias(DomRenderer), bind(APP_ID).toValue('a'), - bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()), DomSharedStylesHost, bind(SharedStylesHost).toAlias(DomSharedStylesHost), AppViewPool, @@ -123,14 +113,9 @@ function _getAppBindings() { Log, DynamicComponentLoader, PipeResolver, - Parser, - Lexer, bind(ExceptionHandler).toValue(new ExceptionHandler(DOM)), bind(LocationStrategy).toClass(MockLocationStrategy), bind(XHR).toClass(MockXHR), - UrlResolver, - AnchorBasedAppRootUrl, - bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl), TestComponentBuilder, bind(NgZone).toClass(MockNgZone), bind(AnimationBuilder).toClass(MockAnimationBuilder),