Skip to content

Commit ebe531b

Browse files
committed
feat(transformers): collect data needed for the template compiler
Closes #7299
1 parent 1779caf commit ebe531b

File tree

38 files changed

+1180
-186
lines changed

38 files changed

+1180
-186
lines changed

modules/angular2/src/compiler/directive_metadata.ts

Lines changed: 278 additions & 14 deletions
Large diffs are not rendered by default.

modules/angular2/src/compiler/template_compiler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class TemplateCompiler {
109109
hostProperties: directive.hostProperties,
110110
hostAttributes: directive.hostAttributes,
111111
lifecycleHooks: directive.lifecycleHooks,
112+
providers: directive.providers,
112113
template: normalizedTemplate
113114
}));
114115
}

modules/angular2/src/core/change_detection/change_detector_ref.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {ChangeDetector} from './interfaces';
22
import {ChangeDetectionStrategy} from './constants';
3+
import {Injectable} from 'angular2/src/core/di';
34

5+
@Injectable()
46
export abstract class ChangeDetectorRef {
57
/**
68
* Marks all {@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.

modules/angular2/src/core/linker/element_ref.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {unimplemented} from 'angular2/src/facade/exceptions';
2+
import {Injectable} from 'angular2/src/core/di';
23
import {AppElement} from './element';
34

45
/**
@@ -11,6 +12,7 @@ import {AppElement} from './element';
1112
* An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
1213
* element.
1314
*/
15+
@Injectable()
1416
export abstract class ElementRef {
1517
/**
1618
* The underlying native element or `null` if direct access to native elements is not supported

modules/angular2/src/core/linker/template_ref.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {ElementRef, ElementRef_} from './element_ref';
2+
import {Injectable} from 'angular2/src/core/di';
23

34
/**
45
* Represents an Embedded Template that can be used to instantiate Embedded Views.
@@ -12,6 +13,7 @@ import {ElementRef, ElementRef_} from './element_ref';
1213
* {@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
1314
* View Container.
1415
*/
16+
@Injectable()
1517
export abstract class TemplateRef {
1618
/**
1719
* The location in the View where the Embedded View logically belongs to.

modules/angular2/src/core/linker/view_container_ref.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ListWrapper} from 'angular2/src/facade/collection';
22
import {unimplemented} from 'angular2/src/facade/exceptions';
3-
import {ResolvedProvider} from 'angular2/src/core/di';
3+
import {ResolvedProvider, Injectable} from 'angular2/src/core/di';
44
import {isPresent, isBlank} from 'angular2/src/facade/lang';
55

66
import {AppElement} from './element';
@@ -36,6 +36,7 @@ import {
3636
*
3737
* <!-- TODO(i): we are also considering ElementRef#viewContainer api -->
3838
*/
39+
@Injectable()
3940
export abstract class ViewContainerRef {
4041
/**
4142
* Anchor element that specifies the location of this container in the containing View.

modules/angular2/src/core/render/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {ViewEncapsulation} from 'angular2/src/core/metadata/view';
2-
import {Injector} from 'angular2/src/core/di/injector';
2+
import {Injector, Injectable} from 'angular2/src/core/di';
33

44
export class RenderComponentType {
55
constructor(public id: string, public encapsulation: ViewEncapsulation,
@@ -13,6 +13,7 @@ export class RenderDebugInfo {
1313

1414
export interface ParentRenderer { renderComponent(componentType: RenderComponentType): Renderer; }
1515

16+
@Injectable()
1617
export abstract class Renderer implements ParentRenderer {
1718
abstract renderComponent(componentType: RenderComponentType): Renderer;
1819

modules/angular2/src/router/router.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let _resolveToFalse = PromiseWrapper.resolve(false);
3434
* `Instruction`.
3535
* The router uses the `RouteRegistry` to get an `Instruction`.
3636
*/
37+
@Injectable()
3738
export class Router {
3839
navigating: boolean = false;
3940
lastNavigationAttempt: string;

modules/angular2/test/compiler/directive_metadata_spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
import {
1616
CompileDirectiveMetadata,
1717
CompileTypeMetadata,
18-
CompileTemplateMetadata
18+
CompileTemplateMetadata,
19+
CompileProviderMetadata
1920
} from 'angular2/src/compiler/directive_metadata';
2021
import {ViewEncapsulation} from 'angular2/src/core/metadata/view';
2122
import {ChangeDetectionStrategy} from 'angular2/src/core/change_detection';
@@ -28,8 +29,8 @@ export function main() {
2829
var fullDirectiveMeta: CompileDirectiveMetadata;
2930

3031
beforeEach(() => {
31-
fullTypeMeta =
32-
new CompileTypeMetadata({name: 'SomeType', moduleUrl: 'someUrl', isHost: true});
32+
fullTypeMeta = new CompileTypeMetadata(
33+
{name: 'SomeType', moduleUrl: 'someUrl', isHost: true, diDeps: []});
3334
fullTemplateMeta = new CompileTemplateMetadata({
3435
encapsulation: ViewEncapsulation.Emulated,
3536
template: '<a></a>',
@@ -48,7 +49,8 @@ export function main() {
4849
inputs: ['someProp'],
4950
outputs: ['someEvent'],
5051
host: {'(event1)': 'handler1', '[prop1]': 'expr1', 'attr1': 'attrValue2'},
51-
lifecycleHooks: [LifecycleHooks.OnChanges]
52+
lifecycleHooks: [LifecycleHooks.OnChanges],
53+
providers: [new CompileProviderMetadata({token: 'token', useClass: fullTypeMeta})]
5254
});
5355

5456
});

modules/angular2/test/public_api_spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,15 @@ var NG_COMPILER = [
530530
"CompileDirectiveMetadata.template=",
531531
"CompileDirectiveMetadata.type",
532532
"CompileDirectiveMetadata.type=",
533+
"CompileDirectiveMetadata.identifier",
534+
"CompileDirectiveMetadata.providers",
535+
"CompileDirectiveMetadata.providers=",
536+
"CompileDirectiveMetadata.queries",
537+
"CompileDirectiveMetadata.queries=",
538+
"CompileDirectiveMetadata.viewProviders",
539+
"CompileDirectiveMetadata.viewProviders=",
540+
"CompileDirectiveMetadata.viewQueries",
541+
"CompileDirectiveMetadata.viewQueries=",
533542
"CompileTemplateMetadata.encapsulation",
534543
"CompileTemplateMetadata.encapsulation=",
535544
"CompileTemplateMetadata.ngContentSelectors",
@@ -550,6 +559,14 @@ var NG_COMPILER = [
550559
"CompileTypeMetadata.name=",
551560
"CompileTypeMetadata.runtime",
552561
"CompileTypeMetadata.runtime=",
562+
"CompileTypeMetadata.diDeps",
563+
"CompileTypeMetadata.diDeps=",
564+
"CompileTypeMetadata.type",
565+
"CompileTypeMetadata.identifier",
566+
"CompileTypeMetadata.prefix",
567+
"CompileTypeMetadata.prefix=",
568+
"CompileTypeMetadata.constConstructor",
569+
"CompileTypeMetadata.constConstructor=",
553570
"DirectiveAst.directive",
554571
"DirectiveAst.directive=",
555572
"DirectiveAst.exportAsVars",

0 commit comments

Comments
 (0)