style(lint): re-format modules/@angular

This commit is contained in:
Alex Eagle
2016-06-08 16:38:52 -07:00
parent bbed364e7b
commit f39c9c9e75
589 changed files with 21829 additions and 24259 deletions

View File

@ -1,4 +1,5 @@
export {CodeGenerator} from './src/codegen';
export {ReflectorHost, ReflectorHostContext, NodeReflectorHostContext} from './src/reflector_host';
export {NodeReflectorHostContext, ReflectorHost, ReflectorHostContext} from './src/reflector_host';
export {StaticReflector, StaticReflectorHost, StaticSymbol} from './src/static_reflector';
export * from '@angular/tsc-wrapped';

View File

@ -21,7 +21,10 @@ export class HasCustomDecorator {
}
// Verify that custom decorators have metadata collected, eg Ionic
export function Page(c: any): (f: Function) => void {return c;}
export function Page(c: any): (f: Function) => void {
return c;
}
@Page({template: 'Ionic template'})
export class AnIonicPage {}
export class AnIonicPage {
}

View File

@ -1,17 +1,15 @@
import {AUTO_STYLE, Component, trigger, state, animate, transition, style} from '@angular/core';
import {AUTO_STYLE, Component, animate, state, style, transition, trigger} from '@angular/core';
@Component({
selector: "animate-cmp",
animations: [
trigger('openClose', [
state("*", style({ height: AUTO_STYLE, color: 'black', borderColor: 'black' })),
state('closed, void',
style({ height:"0px", color: "maroon", borderColor: "maroon" })),
state('open',
style({ height: AUTO_STYLE, borderColor:"green", color:"green" })),
transition("* => *", animate(500))
])
],
selector: 'animate-cmp',
animations: [trigger(
'openClose',
[
state('*', style({height: AUTO_STYLE, color: 'black', borderColor: 'black'})),
state('closed, void', style({height: '0px', color: 'maroon', borderColor: 'maroon'})),
state('open', style({height: AUTO_STYLE, borderColor: 'green', color: 'green'})),
transition('* => *', animate(500))
])],
template: `
<button (click)="setAsOpen()">Open</button>
<button (click)="setAsClosed()">Closed</button>
@ -23,17 +21,9 @@ import {AUTO_STYLE, Component, trigger, state, animate, transition, style} from
`
})
export class AnimateCmp {
stateExpression:string;
constructor() {
this.setAsClosed();
}
setAsSomethingElse() {
this.stateExpression = 'something';
}
setAsOpen() {
this.stateExpression = 'open';
}
setAsClosed() {
this.stateExpression = 'closed';
}
stateExpression: string;
constructor() { this.setAsClosed(); }
setAsSomethingElse() { this.stateExpression = 'something'; }
setAsOpen() { this.stateExpression = 'open'; }
setAsClosed() { this.stateExpression = 'closed'; }
}

View File

@ -1,5 +1,6 @@
import {FORM_DIRECTIVES, NgFor, NgIf} from '@angular/common';
import {Component, Inject} from '@angular/core';
import {FORM_DIRECTIVES, NgIf, NgFor} from '@angular/common';
import {MyComp} from './a/multiple_components';
@Component({

View File

@ -1,7 +1,8 @@
import {coreBootstrap, ReflectiveInjector} from '@angular/core';
import {browserPlatform, BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
import {BasicNgFactory} from './basic.ngfactory';
import {ReflectiveInjector, coreBootstrap} from '@angular/core';
import {BROWSER_APP_PROVIDERS, browserPlatform} from '@angular/platform-browser';
import {Basic} from './basic';
import {BasicNgFactory} from './basic.ngfactory';
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);

View File

@ -1,5 +1,5 @@
import {Component, Inject, OpaqueToken} from '@angular/core';
import * as common from '@angular/common';
import {Component, Inject, OpaqueToken} from '@angular/core';
export const SOME_OPAQUE_TOKEN = new OpaqueToken('opaqueToken');

View File

@ -1,9 +1,6 @@
import {Component} from '@angular/core';
@Component({
selector: 'comp-with-proj',
template: '<ng-content></ng-content>'
})
@Component({selector: 'comp-with-proj', template: '<ng-content></ng-content>'})
export class CompWithProjection {
}
@ -12,4 +9,5 @@ export class CompWithProjection {
template: '<comp-with-proj><span greeting="Hello world!"></span></comp-with-proj>',
directives: [CompWithProjection]
})
export class MainComp {}
export class MainComp {
}

View File

@ -7,16 +7,16 @@ import {AnimateCmpNgFactory} from '../src/animate.ngfactory';
import {AUTO_STYLE, ReflectiveInjector, DebugElement, getDebugNode} from '@angular/core';
import {browserPlatform, BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
describe("template codegen output", () => {
describe('template codegen output', () => {
function findTargetElement(elm: DebugElement): DebugElement {
// the open-close-container is a child of the main container
// if the template changes then please update the location below
return elm.children[4];
}
it("should apply the animate states to the element", (done) => {
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS,
browserPlatform().injector);
it('should apply the animate states to the element', (done) => {
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
var comp = AnimateCmpNgFactory.create(appInjector);
var debugElement = <DebugElement>getDebugNode(comp.location.nativeElement);
@ -34,7 +34,7 @@ describe("template codegen output", () => {
comp.changeDetectorRef.detectChanges();
setTimeout(() => {
expect(targetDebugElement.styles['height']).toEqual("0px");
expect(targetDebugElement.styles['height']).toEqual('0px');
expect(targetDebugElement.styles['borderColor']).toEqual('maroon');
expect(targetDebugElement.styles['color']).toEqual('maroon');
done();
@ -42,9 +42,9 @@ describe("template codegen output", () => {
}, 0);
});
it("should apply the default animate state to the element", (done) => {
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS,
browserPlatform().injector);
it('should apply the default animate state to the element', (done) => {
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
var comp = AnimateCmpNgFactory.create(appInjector);
var debugElement = <DebugElement>getDebugNode(comp.location.nativeElement);

View File

@ -13,16 +13,16 @@ import {MyComp} from '../src/a/multiple_components';
import {ReflectiveInjector, DebugElement, getDebugNode} from '@angular/core';
import {browserPlatform, BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
describe("template codegen output", () => {
describe('template codegen output', () => {
const outDir = 'src';
it("should lower Decorators without reflect-metadata", () => {
it('should lower Decorators without reflect-metadata', () => {
const jsOutput = path.join(outDir, 'basic.js');
expect(fs.existsSync(jsOutput)).toBeTruthy();
expect(fs.readFileSync(jsOutput, {encoding: 'utf-8'})).not.toContain('Reflect.decorate');
});
it("should produce metadata.json outputs", () => {
it('should produce metadata.json outputs', () => {
const metadataOutput = path.join(outDir, 'basic.metadata.json');
expect(fs.existsSync(metadataOutput)).toBeTruthy();
const output = fs.readFileSync(metadataOutput, {encoding: 'utf-8'});
@ -30,22 +30,22 @@ describe("template codegen output", () => {
expect(output).toContain('"module":"@angular/core","name":"Component"');
});
it("should write .d.ts files", () => {
it('should write .d.ts files', () => {
const dtsOutput = path.join(outDir, 'basic.d.ts');
expect(fs.existsSync(dtsOutput)).toBeTruthy();
expect(fs.readFileSync(dtsOutput, {encoding: 'utf-8'})).toContain('Basic');
});
it("should be able to create the basic component", () => {
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS,
browserPlatform().injector);
it('should be able to create the basic component', () => {
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
var comp = BasicNgFactory.create(appInjector);
expect(comp.instance).toBeTruthy();
});
it("should support ngIf", () => {
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS,
browserPlatform().injector);
it('should support ngIf', () => {
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
var comp = BasicNgFactory.create(appInjector);
var debugElement = <DebugElement>getDebugNode(comp.location.nativeElement);
expect(debugElement.children.length).toBe(2);
@ -56,9 +56,9 @@ describe("template codegen output", () => {
expect(debugElement.children[2].injector.get(MyComp)).toBeTruthy();
});
it("should support ngFor", () => {
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS,
browserPlatform().injector);
it('should support ngFor', () => {
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
var comp = BasicNgFactory.create(appInjector);
var debugElement = <DebugElement>getDebugNode(comp.location.nativeElement);
expect(debugElement.children.length).toBe(2);

View File

@ -10,10 +10,10 @@ let serializer = require('@angular/compiler/src/i18n/xmb_serializer.js');
import * as fs from 'fs';
import * as path from 'path';
describe("template i18n extraction output", () => {
describe('template i18n extraction output', () => {
const outDir = '';
it("should extract i18n messages", () => {
it('should extract i18n messages', () => {
const xmbOutput = path.join(outDir, 'messages.xmb');
expect(fs.existsSync(xmbOutput)).toBeTruthy();
const xmb = fs.readFileSync(xmbOutput, {encoding: 'utf-8'});

View File

@ -1,11 +1,13 @@
import {MainCompNgFactory} from '../src/projection.ngfactory';
import {CompWithProjection} from '../src/projection';
import {ReflectiveInjector, DebugElement, getDebugNode} from '@angular/core';
import {browserPlatform, BROWSER_APP_PROVIDERS, By} from '@angular/platform-browser';
import {DebugElement, ReflectiveInjector, getDebugNode} from '@angular/core';
import {BROWSER_APP_PROVIDERS, By, browserPlatform} from '@angular/platform-browser';
describe("content projection", () => {
it("should support basic content projection", () => {
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
import {CompWithProjection} from '../src/projection';
import {MainCompNgFactory} from '../src/projection.ngfactory';
describe('content projection', () => {
it('should support basic content projection', () => {
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector);
var mainComp = MainCompNgFactory.create(appInjector);
var debugElement = <DebugElement>getDebugNode(mainComp.location.nativeElement);

View File

@ -2,30 +2,17 @@
* Transform template html and css into executable code.
* Intended to be used in a build step.
*/
import * as ts from 'typescript';
import * as path from 'path';
import {AngularCompilerOptions} from '@angular/tsc-wrapped';
import * as compiler from '@angular/compiler';
import {ViewEncapsulation} from '@angular/core';
import {StaticReflector} from './static_reflector';
import {
CompileMetadataResolver,
HtmlParser,
DirectiveNormalizer,
Lexer,
Parser,
TemplateParser,
DomElementSchemaRegistry,
StyleCompiler,
ViewCompiler,
TypeScriptEmitter
} from './compiler_private';
import {Parse5DomAdapter} from '@angular/platform-server';
import {AngularCompilerOptions} from '@angular/tsc-wrapped';
import * as path from 'path';
import * as ts from 'typescript';
import {CompileMetadataResolver, DirectiveNormalizer, DomElementSchemaRegistry, HtmlParser, Lexer, Parser, StyleCompiler, TemplateParser, TypeScriptEmitter, ViewCompiler} from './compiler_private';
import {ReflectorHost, ReflectorHostContext} from './reflector_host';
import {StaticAndDynamicReflectionCapabilities} from './static_reflection_capabilities';
import {StaticReflector} from './static_reflector';
const GENERATED_FILES = /\.ngfactory\.ts$|\.css\.ts$|\.css\.shim\.ts$/;
@ -38,11 +25,11 @@ const PREAMBLE = `/**
`;
export class CodeGenerator {
constructor(private options: AngularCompilerOptions,
private program: ts.Program, public host: ts.CompilerHost,
private staticReflector: StaticReflector, private resolver: CompileMetadataResolver,
private compiler: compiler.OfflineCompiler,
private reflectorHost: ReflectorHost) {}
constructor(
private options: AngularCompilerOptions, private program: ts.Program,
public host: ts.CompilerHost, private staticReflector: StaticReflector,
private resolver: CompileMetadataResolver, private compiler: compiler.OfflineCompiler,
private reflectorHost: ReflectorHost) {}
private generateSource(metadatas: compiler.CompileDirectiveMetadata[]) {
const normalize = (metadata: compiler.CompileDirectiveMetadata) => {
@ -51,13 +38,14 @@ export class CodeGenerator {
return Promise.all(directives.map(d => this.compiler.normalizeDirectiveMetadata(d)))
.then(normalizedDirectives => {
const pipes = this.resolver.getViewPipesMetadata(directiveType);
return new compiler.NormalizedComponentWithViewDirectives(metadata,
normalizedDirectives, pipes);
return new compiler.NormalizedComponentWithViewDirectives(
metadata, normalizedDirectives, pipes);
});
};
return Promise.all(metadatas.map(normalize))
.then(normalizedCompWithDirectives =>
this.compiler.compileTemplates(normalizedCompWithDirectives));
.then(
normalizedCompWithDirectives =>
this.compiler.compileTemplates(normalizedCompWithDirectives));
}
private readComponents(absSourcePath: string) {
@ -142,8 +130,8 @@ export class CodeGenerator {
if (generated) {
const sourceFile = this.program.getSourceFile(absSourcePath);
const emitPath = this.calculateEmitPath(generated.moduleUrl);
this.host.writeFile(emitPath, PREAMBLE + generated.source, false, () => {},
[sourceFile]);
this.host.writeFile(
emitPath, PREAMBLE + generated.source, false, () => {}, [sourceFile]);
}
})
.catch((e) => { console.error(e.stack); });
@ -154,9 +142,9 @@ export class CodeGenerator {
return Promise.all(stylesheetPromises.concat(compPromises));
}
static create(options: AngularCompilerOptions, program: ts.Program,
compilerHost: ts.CompilerHost,
reflectorHostContext?: ReflectorHostContext): CodeGenerator {
static create(
options: AngularCompilerOptions, program: ts.Program, compilerHost: ts.CompilerHost,
reflectorHostContext?: ReflectorHostContext): CodeGenerator {
const xhr: compiler.XHR = {get: (s: string) => Promise.resolve(compilerHost.readFile(s))};
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
const reflectorHost = new ReflectorHost(program, compilerHost, options, reflectorHostContext);
@ -166,8 +154,9 @@ export class CodeGenerator {
const config = new compiler.CompilerConfig(true, true, true);
const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config);
const parser = new Parser(new Lexer());
const tmplParser = new TemplateParser(parser, new DomElementSchemaRegistry(), htmlParser,
/*console*/ null, []);
const tmplParser = new TemplateParser(
parser, new DomElementSchemaRegistry(), htmlParser,
/*console*/ null, []);
const offlineCompiler = new compiler.OfflineCompiler(
normalizer, tmplParser, new StyleCompiler(urlResolver),
new ViewCompiler(new compiler.CompilerConfig(true, true, true)),
@ -176,7 +165,7 @@ export class CodeGenerator {
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
new compiler.ViewResolver(staticReflector), null, null, staticReflector);
return new CodeGenerator(options, program, compilerHost, staticReflector, resolver,
offlineCompiler, reflectorHost);
return new CodeGenerator(
options, program, compilerHost, staticReflector, resolver, offlineCompiler, reflectorHost);
}
}

View File

@ -4,7 +4,7 @@ export type AssetUrl = _c.AssetUrl;
export var AssetUrl: typeof _c.AssetUrl = _c.AssetUrl;
export type ImportGenerator = _c.ImportGenerator;
export var ImportGenerator: typeof _c.ImportGenerator = _c.ImportGenerator;
export var ImportGenerator: typeof _c.ImportGenerator = _c.ImportGenerator;
export type CompileMetadataResolver = _c.CompileMetadataResolver;
export var CompileMetadataResolver: typeof _c.CompileMetadataResolver = _c.CompileMetadataResolver;

View File

@ -13,24 +13,7 @@ import * as path from 'path';
import * as compiler from '@angular/compiler';
import {StaticReflector} from './static_reflector';
import {
CompileMetadataResolver,
HtmlParser,
DirectiveNormalizer,
Lexer,
Parser,
TemplateParser,
DomElementSchemaRegistry,
StyleCompiler,
ViewCompiler,
TypeScriptEmitter,
MessageExtractor,
removeDuplicates,
ExtractionResult,
Message,
ParseError,
serializeXmb,
} from './compiler_private';
import {CompileMetadataResolver, HtmlParser, DirectiveNormalizer, Lexer, Parser, TemplateParser, DomElementSchemaRegistry, StyleCompiler, ViewCompiler, TypeScriptEmitter, MessageExtractor, removeDuplicates, ExtractionResult, Message, ParseError, serializeXmb,} from './compiler_private';
import {Parse5DomAdapter} from '@angular/platform-server';
@ -38,20 +21,22 @@ import {ReflectorHost} from './reflector_host';
import {StaticAndDynamicReflectionCapabilities} from './static_reflection_capabilities';
function extract(ngOptions: tsc.AngularCompilerOptions, program: ts.Program, host: ts.CompilerHost) {
function extract(
ngOptions: tsc.AngularCompilerOptions, program: ts.Program, host: ts.CompilerHost) {
return Extractor.create(ngOptions, program, host).extract();
}
const GENERATED_FILES = /\.ngfactory\.ts$|\.css\.ts$|\.css\.shim\.ts$/;
class Extractor {
constructor(private options: tsc.AngularCompilerOptions,
private program: ts.Program, public host: ts.CompilerHost,
private staticReflector: StaticReflector, private resolver: CompileMetadataResolver,
private compiler: compiler.OfflineCompiler,
private reflectorHost: ReflectorHost, private _extractor: MessageExtractor) {}
constructor(
private options: tsc.AngularCompilerOptions, private program: ts.Program,
public host: ts.CompilerHost, private staticReflector: StaticReflector,
private resolver: CompileMetadataResolver, private compiler: compiler.OfflineCompiler,
private reflectorHost: ReflectorHost, private _extractor: MessageExtractor) {}
private extractCmpMessages(metadatas: compiler.CompileDirectiveMetadata[]): Promise<ExtractionResult> {
private extractCmpMessages(metadatas: compiler.CompileDirectiveMetadata[]):
Promise<ExtractionResult> {
if (!metadatas || !metadatas.length) {
return null;
}
@ -60,28 +45,27 @@ class Extractor {
const directiveType = metadata.type.runtime;
const directives = this.resolver.getViewDirectivesMetadata(directiveType);
return Promise.all(directives.map(d => this.compiler.normalizeDirectiveMetadata(d)))
.then(normalizedDirectives => {
const pipes = this.resolver.getViewPipesMetadata(directiveType);
return new compiler.NormalizedComponentWithViewDirectives(metadata,
normalizedDirectives, pipes);
});
.then(normalizedDirectives => {
const pipes = this.resolver.getViewPipesMetadata(directiveType);
return new compiler.NormalizedComponentWithViewDirectives(
metadata, normalizedDirectives, pipes);
});
};
return Promise
.all(metadatas.map(normalize))
.then((cmps: compiler.NormalizedComponentWithViewDirectives[]) => {
let messages: Message[] = [];
let errors: ParseError[] = [];
cmps.forEach(cmp => {
// TODO(vicb): url
let result = this._extractor.extract(cmp.component.template.template, "url");
errors = errors.concat(result.errors);
messages = messages.concat(result.messages);
});
return Promise.all(metadatas.map(normalize))
.then((cmps: compiler.NormalizedComponentWithViewDirectives[]) => {
let messages: Message[] = [];
let errors: ParseError[] = [];
cmps.forEach(cmp => {
// TODO(vicb): url
let result = this._extractor.extract(cmp.component.template.template, 'url');
errors = errors.concat(result.errors);
messages = messages.concat(result.messages);
});
// Extraction Result might contain duplicate messages at this point
return new ExtractionResult(messages, errors);
});
// Extraction Result might contain duplicate messages at this point
return new ExtractionResult(messages, errors);
});
}
private readComponents(absSourcePath: string) {
@ -113,42 +97,39 @@ class Extractor {
Parse5DomAdapter.makeCurrent();
const promises = this.program.getSourceFiles()
.map(sf => sf.fileName)
.filter(f => !GENERATED_FILES.test(f))
.map((absSourcePath:string): Promise<any> =>
Promise
.all(this.readComponents(absSourcePath))
.then(metadatas => this.extractCmpMessages(metadatas))
.catch(e => console.error(e.stack))
);
.map(sf => sf.fileName)
.filter(f => !GENERATED_FILES.test(f))
.map(
(absSourcePath: string): Promise<any> =>
Promise.all(this.readComponents(absSourcePath))
.then(metadatas => this.extractCmpMessages(metadatas))
.catch(e => console.error(e.stack)));
let messages: Message[] = [];
let errors: ParseError[] = [];
return Promise.all(promises)
.then(extractionResults => {
extractionResults
.filter(result => !!result)
.forEach(result => {
messages = messages.concat(result.messages);
errors = errors.concat(result.errors);
});
if (errors.length) {
throw errors;
}
messages = removeDuplicates(messages);
let genPath = path.join(this.options.genDir, 'messages.xmb');
let msgBundle = serializeXmb(messages);
this.host.writeFile(genPath, msgBundle, false);
return Promise.all(promises).then(extractionResults => {
extractionResults.filter(result => !!result).forEach(result => {
messages = messages.concat(result.messages);
errors = errors.concat(result.errors);
});
if (errors.length) {
throw errors;
}
messages = removeDuplicates(messages);
let genPath = path.join(this.options.genDir, 'messages.xmb');
let msgBundle = serializeXmb(messages);
this.host.writeFile(genPath, msgBundle, false);
});
}
static create(options: tsc.AngularCompilerOptions, program: ts.Program,
compilerHost: ts.CompilerHost): Extractor {
static create(
options: tsc.AngularCompilerOptions, program: ts.Program,
compilerHost: ts.CompilerHost): Extractor {
const xhr: compiler.XHR = {get: (s: string) => Promise.resolve(compilerHost.readFile(s))};
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
const reflectorHost = new ReflectorHost(program, compilerHost, options);
@ -158,21 +139,22 @@ class Extractor {
const config = new compiler.CompilerConfig(true, true, true);
const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config);
const parser = new Parser(new Lexer());
const tmplParser = new TemplateParser(parser, new DomElementSchemaRegistry(), htmlParser,
/*console*/ null, []);
const tmplParser = new TemplateParser(
parser, new DomElementSchemaRegistry(), htmlParser,
/*console*/ null, []);
const offlineCompiler = new compiler.OfflineCompiler(
normalizer, tmplParser, new StyleCompiler(urlResolver),
new ViewCompiler(config),
new TypeScriptEmitter(reflectorHost), xhr);
normalizer, tmplParser, new StyleCompiler(urlResolver), new ViewCompiler(config),
new TypeScriptEmitter(reflectorHost), xhr);
const resolver = new CompileMetadataResolver(
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
new compiler.ViewResolver(staticReflector), null, null, staticReflector);
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
new compiler.ViewResolver(staticReflector), null, null, staticReflector);
// TODO(vicb): handle implicit
const extractor = new MessageExtractor(htmlParser, parser, [], {});
return new Extractor(options, program, compilerHost, staticReflector, resolver,
offlineCompiler, reflectorHost, extractor);
return new Extractor(
options, program, compilerHost, staticReflector, resolver, offlineCompiler, reflectorHost,
extractor);
}
}
@ -180,11 +162,10 @@ class Extractor {
if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
tsc.main(args.p || args.project || '.', args.basePath, extract)
.then(exitCode => process.exit(exitCode))
.catch(e => {
console.error(e.stack);
console.error("Compilation failed");
process.exit(1);
});
.then(exitCode => process.exit(exitCode))
.catch(e => {
console.error(e.stack);
console.error('Compilation failed');
process.exit(1);
});
}

View File

@ -8,7 +8,8 @@ import * as tsc from '@angular/tsc-wrapped';
import {CodeGenerator} from './codegen';
function codegen(ngOptions: tsc.AngularCompilerOptions, program: ts.Program, host: ts.CompilerHost) {
function codegen(
ngOptions: tsc.AngularCompilerOptions, program: ts.Program, host: ts.CompilerHost) {
return CodeGenerator.create(ngOptions, program, host).codegen();
}
@ -19,7 +20,7 @@ if (require.main === module) {
.then(exitCode => process.exit(exitCode))
.catch(e => {
console.error(e.stack);
console.error("Compilation failed");
console.error('Compilation failed');
process.exit(1);
});
}

View File

@ -1,9 +1,10 @@
import {StaticReflectorHost, StaticSymbol} from './static_reflector';
import * as ts from 'typescript';
import {AngularCompilerOptions, MetadataCollector, ModuleMetadata} from '@angular/tsc-wrapped';
import * as fs from 'fs';
import * as path from 'path';
import {ImportGenerator, AssetUrl} from './compiler_private';
import * as ts from 'typescript';
import {AssetUrl, ImportGenerator} from './compiler_private';
import {StaticReflectorHost, StaticSymbol} from './static_reflector';
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
const DTS = /\.d\.ts$/;
@ -17,9 +18,9 @@ export interface ReflectorHostContext {
export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
private metadataCollector = new MetadataCollector();
private context: ReflectorHostContext;
constructor(private program: ts.Program, private compilerHost: ts.CompilerHost,
private options: AngularCompilerOptions,
context?: ReflectorHostContext) {
constructor(
private program: ts.Program, private compilerHost: ts.CompilerHost,
private options: AngularCompilerOptions, context?: ReflectorHostContext) {
this.context = context || new NodeReflectorHostContext();
}
@ -94,11 +95,12 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
`Unable to find any resolvable import for ${importedFile} relative to ${containingFile}`);
}
findDeclaration(module: string, symbolName: string, containingFile: string,
containingModule?: string): StaticSymbol {
findDeclaration(
module: string, symbolName: string, containingFile: string,
containingModule?: string): StaticSymbol {
if (!containingFile || !containingFile.length) {
if (module.indexOf(".") === 0) {
throw new Error("Resolution of relative paths requires a containing file.");
if (module.indexOf('.') === 0) {
throw new Error('Resolution of relative paths requires a containing file.');
}
// Any containing file gives the same result for absolute imports
containingFile = path.join(this.options.basePath, 'index.ts');
@ -195,15 +197,9 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
}
export class NodeReflectorHostContext implements ReflectorHostContext {
exists(fileName: string): boolean {
return fs.existsSync(fileName);
}
exists(fileName: string): boolean { return fs.existsSync(fileName); }
read(fileName: string): string {
return fs.readFileSync(fileName, 'utf8');
}
read(fileName: string): string { return fs.readFileSync(fileName, 'utf8'); }
write(fileName: string, data: string): void {
fs.writeFileSync(fileName, data, 'utf8');
}
write(fileName: string, data: string): void { fs.writeFileSync(fileName, data, 'utf8'); }
}

View File

@ -15,8 +15,8 @@ export class StaticAndDynamicReflectionCapabilities {
interfaces(type: any): any[] { return this.dynamicDelegate.interfaces(type); }
hasLifecycleHook(type: any, lcInterface: /*Type*/ any, lcProperty: string): boolean {
return isStaticType(type) ?
this.staticDelegate.hasLifecycleHook(type, lcInterface, lcProperty) :
this.dynamicDelegate.hasLifecycleHook(type, lcInterface, lcProperty);
this.staticDelegate.hasLifecycleHook(type, lcInterface, lcProperty) :
this.dynamicDelegate.hasLifecycleHook(type, lcInterface, lcProperty);
}
parameters(type: any): any[][] {
return isStaticType(type) ? this.staticDelegate.parameters(type) :

View File

@ -1,35 +1,6 @@
import {
AttributeMetadata,
DirectiveMetadata,
ComponentMetadata,
ContentChildrenMetadata,
ContentChildMetadata,
InputMetadata,
HostBindingMetadata,
HostListenerMetadata,
OutputMetadata,
PipeMetadata,
ViewChildMetadata,
ViewChildrenMetadata,
ViewQueryMetadata,
QueryMetadata,
Provider,
HostMetadata,
OptionalMetadata,
InjectableMetadata,
SelfMetadata,
SkipSelfMetadata,
InjectMetadata,
trigger,
state,
transition,
sequence,
group,
animate,
style,
keyframes
} from "@angular/core";
import {ReflectorReader} from "./core_private";
import {AttributeMetadata, ComponentMetadata, ContentChildMetadata, ContentChildrenMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, HostMetadata, InjectMetadata, InjectableMetadata, InputMetadata, OptionalMetadata, OutputMetadata, PipeMetadata, Provider, QueryMetadata, SelfMetadata, SkipSelfMetadata, ViewChildMetadata, ViewChildrenMetadata, ViewQueryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
import {ReflectorReader} from './core_private';
const SUPPORTED_SCHEMA_VERSION = 1;
@ -57,8 +28,13 @@ export interface StaticReflectorHost {
getStaticSymbol(declarationFile: string, name: string): StaticSymbol;
angularImportLocations():
{coreDecorators: string, diDecorators: string, diMetadata: string, animationMetadata: string, provider: string};
angularImportLocations(): {
coreDecorators: string,
diDecorators: string,
diMetadata: string,
animationMetadata: string,
provider: string
};
}
/**
@ -167,7 +143,7 @@ export class StaticReflector implements ReflectorReader {
}
let classMetadata = this.getTypeMetadata(type);
let members = classMetadata ? classMetadata['members'] : null;
let member:any[] = members ? members[lcProperty] : null;
let member: any[] = members ? members[lcProperty] : null;
return member ? member.some(a => a['__symbolic'] == 'method') : false;
}
@ -201,59 +177,60 @@ export class StaticReflector implements ReflectorReader {
}
private initializeConversionMap(): void {
const {coreDecorators, diDecorators, diMetadata, animationMetadata, provider} = this.host.angularImportLocations();
const {coreDecorators, diDecorators, diMetadata, animationMetadata, provider} =
this.host.angularImportLocations();
this.registerDecoratorOrConstructor(this.host.findDeclaration(provider, 'Provider'), Provider);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Host'),
HostMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Injectable'),
InjectableMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Self'),
SelfMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'SkipSelf'),
SkipSelfMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Inject'),
InjectMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Optional'),
OptionalMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Attribute'),
AttributeMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Query'),
QueryMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'ViewQuery'),
ViewQueryMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'ContentChild'),
ContentChildMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diDecorators, 'Host'), HostMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diDecorators, 'Injectable'), InjectableMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diDecorators, 'Self'), SelfMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diDecorators, 'SkipSelf'), SkipSelfMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diDecorators, 'Inject'), InjectMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diDecorators, 'Optional'), OptionalMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Attribute'), AttributeMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Query'), QueryMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'ViewQuery'), ViewQueryMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'ContentChild'), ContentChildMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'ContentChildren'), ContentChildrenMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'ViewChild'),
ViewChildMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'ViewChildren'),
ViewChildrenMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Input'),
InputMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Output'),
OutputMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Pipe'),
PipeMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'HostBinding'),
HostBindingMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'HostListener'),
HostListenerMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Directive'),
DirectiveMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Component'),
ComponentMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'ViewChild'), ViewChildMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'ViewChildren'), ViewChildrenMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Input'), InputMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Output'), OutputMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Pipe'), PipeMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'HostBinding'), HostBindingMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'HostListener'), HostListenerMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Directive'), DirectiveMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(coreDecorators, 'Component'), ComponentMetadata);
// Note: Some metadata classes can be used directly with Provider.deps.
this.registerDecoratorOrConstructor(this.host.findDeclaration(diMetadata, 'HostMetadata'),
HostMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diMetadata, 'SelfMetadata'),
SelfMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diMetadata, 'SkipSelfMetadata'),
SkipSelfMetadata);
this.registerDecoratorOrConstructor(this.host.findDeclaration(diMetadata, 'OptionalMetadata'),
OptionalMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diMetadata, 'HostMetadata'), HostMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diMetadata, 'SelfMetadata'), SelfMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diMetadata, 'SkipSelfMetadata'), SkipSelfMetadata);
this.registerDecoratorOrConstructor(
this.host.findDeclaration(diMetadata, 'OptionalMetadata'), OptionalMetadata);
this.registerFunction(this.host.findDeclaration(animationMetadata, 'trigger'), trigger);
this.registerFunction(this.host.findDeclaration(animationMetadata, 'state'), state);
@ -275,7 +252,7 @@ export class StaticReflector implements ReflectorReader {
}
if (expression instanceof Array) {
let result: any[] = [];
for (let item of(<any>expression)) {
for (let item of (<any>expression)) {
result.push(simplify(item));
}
return result;
@ -284,7 +261,7 @@ export class StaticReflector implements ReflectorReader {
if (expression['__symbolic']) {
let staticSymbol: StaticSymbol;
switch (expression['__symbolic']) {
case "binop":
case 'binop':
let left = simplify(expression['left']);
let right = simplify(expression['right']);
switch (expression['operator']) {
@ -330,7 +307,7 @@ export class StaticReflector implements ReflectorReader {
return left % right;
}
return null;
case "pre":
case 'pre':
let operand = simplify(expression['operand']);
switch (expression['operator']) {
case '+':
@ -343,20 +320,20 @@ export class StaticReflector implements ReflectorReader {
return ~operand;
}
return null;
case "index":
case 'index':
let indexTarget = simplify(expression['expression']);
let index = simplify(expression['index']);
if (indexTarget && isPrimitive(index)) return indexTarget[index];
return null;
case "select":
case 'select':
let selectTarget = simplify(expression['expression']);
let member = simplify(expression['member']);
if (selectTarget && isPrimitive(member)) return selectTarget[member];
return null;
case "reference":
case 'reference':
if (expression['module']) {
staticSymbol = _this.host.findDeclaration(expression['module'], expression['name'],
context.filePath);
staticSymbol = _this.host.findDeclaration(
expression['module'], expression['name'], context.filePath);
} else {
staticSymbol = _this.host.getStaticSymbol(context.filePath, expression['name']);
}
@ -368,14 +345,14 @@ export class StaticReflector implements ReflectorReader {
result = _this.simplify(staticSymbol, declarationValue);
}
return result;
case "class":
case 'class':
return context;
case "new":
case "call":
case 'new':
case 'call':
let target = expression['expression'];
if (target['module']) {
staticSymbol =
_this.host.findDeclaration(target['module'], target['name'], context.filePath);
_this.host.findDeclaration(target['module'], target['name'], context.filePath);
} else {
staticSymbol = _this.host.getStaticSymbol(context.filePath, target['name']);
}
@ -389,10 +366,11 @@ export class StaticReflector implements ReflectorReader {
} else {
return context;
}
case "error":
case 'error':
let message = produceErrorMessage(expression);
if (expression['line']) {
message = `${message} (position ${expression['line']}:${expression['character']} in the original .ts file)`;
message =
`${message} (position ${expression['line']}:${expression['character']} in the original .ts file)`;
}
throw new Error(message);
}
@ -405,7 +383,7 @@ export class StaticReflector implements ReflectorReader {
try {
return simplify(value);
} catch(e) {
} catch (e) {
throw new Error(`${e.message}, resolving symbol ${context.name} in ${context.filePath}`);
}
}
@ -418,13 +396,17 @@ export class StaticReflector implements ReflectorReader {
if (!moduleMetadata) {
moduleMetadata = this.host.getMetadataFor(module);
if (Array.isArray(moduleMetadata)) {
moduleMetadata = (<Array<any>>moduleMetadata).find(element => element.version === SUPPORTED_SCHEMA_VERSION) || moduleMetadata[0];
moduleMetadata = (<Array<any>>moduleMetadata)
.find(element => element.version === SUPPORTED_SCHEMA_VERSION) ||
moduleMetadata[0];
}
if (!moduleMetadata) {
moduleMetadata = {__symbolic: "module", version: SUPPORTED_SCHEMA_VERSION, module: module, metadata: {}};
moduleMetadata =
{__symbolic: 'module', version: SUPPORTED_SCHEMA_VERSION, module: module, metadata: {}};
}
if (moduleMetadata['version'] != SUPPORTED_SCHEMA_VERSION) {
throw new Error(`Metadata version mismatch for module ${module}, found version ${moduleMetadata['version']}, expected ${SUPPORTED_SCHEMA_VERSION}`);
throw new Error(
`Metadata version mismatch for module ${module}, found version ${moduleMetadata['version']}, expected ${SUPPORTED_SCHEMA_VERSION}`);
}
this.metadataCache.set(module, moduleMetadata);
}
@ -435,11 +417,10 @@ export class StaticReflector implements ReflectorReader {
let moduleMetadata = this.getModuleMetadata(type.filePath);
let result = moduleMetadata['metadata'][type.name];
if (!result) {
result = {__symbolic: "class"};
result = {__symbolic: 'class'};
}
return result;
}
}
function expandedMessage(error: any): string {
@ -468,8 +449,8 @@ function produceErrorMessage(error: any): string {
return `Error encountered resolving symbol values statically. ${expandedMessage(error)}`;
}
function mapStringMap(input: {[key: string]: any},
transform: (value: any, key: string) => any): {[key: string]: any} {
function mapStringMap(input: {[key: string]: any}, transform: (value: any, key: string) => any):
{[key: string]: any} {
if (!input) return {};
var result: {[key: string]: any} = {};
Object.keys(input).forEach((key) => { result[key] = transform(input[key], key); });
@ -477,5 +458,5 @@ function mapStringMap(input: {[key: string]: any},
}
function isPrimitive(o: any): boolean {
return o === null || (typeof o !== "function" && typeof o !== "object");
return o === null || (typeof o !== 'function' && typeof o !== 'object');
}

View File

@ -4,20 +4,16 @@ import {ReflectorHost, ReflectorHostContext} from '../src/reflector_host';
export type Entry = string | Directory;
export interface Directory {
[name: string]: Entry;
}
export interface Directory { [name: string]: Entry; }
export class MockContext implements ReflectorHostContext {
constructor (public currentDirectory: string, private files: Entry) {}
constructor(public currentDirectory: string, private files: Entry) {}
exists(fileName: string): boolean {
return this.getEntry(fileName) !== undefined;
}
exists(fileName: string): boolean { return this.getEntry(fileName) !== undefined; }
read(fileName: string): string | undefined {
read(fileName: string): string|undefined {
let data = this.getEntry(fileName);
if (typeof data === "string") {
if (typeof data === 'string') {
return data;
}
return undefined;
@ -27,13 +23,13 @@ export class MockContext implements ReflectorHostContext {
let parts = fileName.split('/');
let name = parts.pop();
let entry = this.getEntry(parts);
if (entry && typeof entry !== "string") {
if (entry && typeof entry !== 'string') {
entry[name] = data;
}
}
getEntry(fileName: string | string[]): Entry | undefined {
let parts = typeof fileName === "string" ? fileName.split('/') : fileName;
getEntry(fileName: string|string[]): Entry|undefined {
let parts = typeof fileName === 'string' ? fileName.split('/') : fileName;
if (parts[0]) {
parts = this.currentDirectory.split('/').concat(parts);
}
@ -42,7 +38,7 @@ export class MockContext implements ReflectorHostContext {
let current = this.files;
while (parts.length) {
let part = parts.shift();
if (typeof current === "string") {
if (typeof current === 'string') {
return undefined;
}
let next = (<Directory>current)[part];
@ -60,30 +56,30 @@ function normalize(parts: string[]): string[] {
while (parts.length) {
let part = parts.shift();
switch (part) {
case '.': break;
case '..': result.pop(); break;
default: result.push(part);
case '.':
break;
case '..':
result.pop();
break;
default:
result.push(part);
}
}
return result;
}
export class MockCompilerHost implements ts.CompilerHost {
constructor (private context: MockContext) {}
constructor(private context: MockContext) {}
fileExists(fileName: string): boolean {
return this.context.exists(fileName);
}
fileExists(fileName: string): boolean { return this.context.exists(fileName); }
readFile(fileName: string): string {
return this.context.read(fileName);
}
readFile(fileName: string): string { return this.context.read(fileName); }
directoryExists(directoryName: string): boolean {
return this.context.exists(directoryName);
}
directoryExists(directoryName: string): boolean { return this.context.exists(directoryName); }
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void): ts.SourceFile {
getSourceFile(
fileName: string, languageVersion: ts.ScriptTarget,
onError?: (message: string) => void): ts.SourceFile {
let sourceText = this.context.read(fileName);
if (sourceText) {
return ts.createSourceFile(fileName, sourceText, languageVersion);
@ -96,23 +92,15 @@ export class MockCompilerHost implements ts.CompilerHost {
return ts.getDefaultLibFileName(options);
}
writeFile: ts.WriteFileCallback = (fileName, text) => {
this.context.write(fileName, text);
}
writeFile: ts.WriteFileCallback = (fileName, text) => { this.context.write(fileName, text); }
getCurrentDirectory(): string {
return this.context.currentDirectory;
}
getCanonicalFileName(fileName: string): string {
return fileName;
}
getCanonicalFileName(fileName: string): string { return fileName; }
useCaseSensitiveFileNames(): boolean {
return false;
}
useCaseSensitiveFileNames(): boolean { return false; }
getNewLine(): string {
return '\n';
}
getNewLine(): string { return '\n'; }
}

View File

@ -1,17 +1,9 @@
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing/testing_internal';
import * as ts from 'typescript';
import {
describe,
it,
iit,
expect,
ddescribe,
beforeEach
} from '@angular/core/testing/testing_internal';
import {ReflectorHost, ReflectorHostContext} from '../src/reflector_host';
import {Directory, Entry, MockContext, MockCompilerHost} from './mocks';
import {Directory, Entry, MockCompilerHost, MockContext} from './mocks';
describe('reflector_host', () => {
var context: MockContext;
@ -22,25 +14,30 @@ describe('reflector_host', () => {
beforeEach(() => {
context = new MockContext('/tmp/src', clone(FILES));
host = new MockCompilerHost(context)
program = ts.createProgram(['main.ts'], {
module: ts.ModuleKind.CommonJS,
}, host);
program = ts.createProgram(
['main.ts'], {
module: ts.ModuleKind.CommonJS,
},
host);
// Force a typecheck
let errors = program.getSemanticDiagnostics();
if (errors && errors.length) {
throw new Error('Expected no errors');
}
reflectorHost = new ReflectorHost(program, host, {
genDir: '/tmp/dist',
basePath: '/tmp/src',
skipMetadataEmit: false,
skipTemplateCodegen: false,
trace: false
}, context);
reflectorHost = new ReflectorHost(
program, host, {
genDir: '/tmp/dist',
basePath: '/tmp/src',
skipMetadataEmit: false,
skipTemplateCodegen: false,
trace: false
},
context);
});
it('should provide the import locations for angular', () => {
let {coreDecorators, diDecorators, diMetadata, animationMetadata, provider} = reflectorHost.angularImportLocations();
let {coreDecorators, diDecorators, diMetadata, animationMetadata, provider} =
reflectorHost.angularImportLocations();
expect(coreDecorators).toEqual('@angular/core/src/metadata');
expect(diDecorators).toEqual('@angular/core/src/di/decorators');
expect(diMetadata).toEqual('@angular/core/src/di/metadata');
@ -49,7 +46,8 @@ describe('reflector_host', () => {
});
it('should be able to produce an import from main @angular/core', () => {
expect(reflectorHost.getImportPath('main.ts', 'node_modules/@angular/core.d.ts')).toEqual('@angular/core');
expect(reflectorHost.getImportPath('main.ts', 'node_modules/@angular/core.d.ts'))
.toEqual('@angular/core');
});
it('should be ble to produce an import from main to a sub-directory', () => {
@ -57,7 +55,8 @@ describe('reflector_host', () => {
});
it('should be able to produce an import from to a peer file', () => {
expect(reflectorHost.getImportPath('lib/utils.ts', 'lib/collections.ts')).toEqual('./collections');
expect(reflectorHost.getImportPath('lib/utils.ts', 'lib/collections.ts'))
.toEqual('./collections');
});
it('should be able to produce an import from to a sibling directory', () => {
@ -69,7 +68,8 @@ describe('reflector_host', () => {
});
it('should be able to produce a symbol for values space only reference', () => {
expect(reflectorHost.findDeclaration('@angular/router/src/providers', 'foo', 'main.ts')).toBeDefined();
expect(reflectorHost.findDeclaration('@angular/router/src/providers', 'foo', 'main.ts'))
.toBeDefined();
});
it('should be produce the same symbol if asked twice', () => {
@ -78,17 +78,10 @@ describe('reflector_host', () => {
expect(foo1).toBe(foo2);
});
it('should be able to read a metadata file', () => {
expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts')).toEqual({
__symbolic: "module",
version: 1,
metadata: {
foo: {
__symbolic: "class"
}
}
})
});
it('should be able to read a metadata file',
() => {
expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts'))
.toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}})});
});
const dummyModule = 'export let foo: any[];'
@ -106,19 +99,13 @@ const FILES: Entry = {
'utils.ts': dummyModule,
'collections.ts': dummyModule,
},
'lib2': {
'utils2.ts': dummyModule
},
'lib2': {'utils2.ts': dummyModule},
'node_modules': {
'@angular': {
'core.d.ts': dummyModule,
'core.metadata.json': `{"__symbolic":"module", "version": 1, "metadata": {"foo": {"__symbolic": "class"}}}`,
'router': {
'index.d.ts': dummyModule,
'src': {
'providers.d.ts': dummyModule
}
}
'core.metadata.json':
`{"__symbolic":"module", "version": 1, "metadata": {"foo": {"__symbolic": "class"}}}`,
'router': {'index.d.ts': dummyModule, 'src': {'providers.d.ts': dummyModule}}
}
}
}
@ -126,7 +113,7 @@ const FILES: Entry = {
}
function clone(entry: Entry): Entry {
if (typeof entry === "string") {
if (typeof entry === 'string') {
return entry;
} else {
let result: Directory = {};

View File

@ -1,21 +1,8 @@
import {
describe,
it,
iit,
expect,
ddescribe,
beforeEach
} from '@angular/core/testing/testing_internal';
import {isBlank} from '@angular/facade/src/lang';
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector';
import {animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing/testing_internal';
import {ListWrapper} from '@angular/facade/src/collection';
import {
StaticReflector,
StaticReflectorHost,
StaticSymbol
} from '@angular/compiler-cli/src/static_reflector';
import {transition, sequence, group, trigger, state, style, animate, keyframes} from '@angular/core';
import {isBlank} from '@angular/facade/src/lang';
describe('StaticReflector', () => {
let noContext = new StaticSymbol('', '');
@ -51,8 +38,9 @@ describe('StaticReflector', () => {
'angular2/src/core/change_detection/change_detector_ref', 'ChangeDetectorRef');
let parameters = reflector.parameters(NgFor);
expect(parameters)
.toEqual([[ViewContainerRef], [TemplateRef], [IterableDiffers], [ChangeDetectorRef]]);
expect(parameters).toEqual([
[ViewContainerRef], [TemplateRef], [IterableDiffers], [ChangeDetectorRef]
]);
});
it('should get annotations for HeroDetailComponent', () => {
@ -62,26 +50,23 @@ describe('StaticReflector', () => {
expect(annotations.length).toEqual(1);
let annotation = annotations[0];
expect(annotation.selector).toEqual('my-hero-detail');
expect(annotation.directives)
.toEqual([[host.findDeclaration('angular2/src/common/directives/ng_for', 'NgFor')]]);
expect(annotation.animations).toEqual([
trigger("myAnimation", [
state("state1", style({ "background": "white" })),
transition("* => *", sequence([
group([
animate("1s 0.5s", keyframes([
style({ "background": "blue"}),
style({ "background": "red"})
]))
])
]))
])
]);
expect(annotation.directives).toEqual([[host.findDeclaration(
'angular2/src/common/directives/ng_for', 'NgFor')]]);
expect(annotation.animations).toEqual([trigger('myAnimation', [
state('state1', style({'background': 'white'})),
transition(
'* => *',
sequence([group([animate(
'1s 0.5s',
keyframes([style({'background': 'blue'}), style({'background': 'red'})]))])]))
])]);
});
it('should throw and exception for unsupported metadata versions', () => {
let e = host.findDeclaration('src/version-error', 'e');
expect(() => reflector.annotations(e)).toThrow(new Error('Metadata version mismatch for module /tmp/src/version-error.d.ts, found version 100, expected 1'));
expect(() => reflector.annotations(e))
.toThrow(new Error(
'Metadata version mismatch for module /tmp/src/version-error.d.ts, found version 100, expected 1'));
});
it('should get and empty annotation list for an unknown class', () => {
@ -111,17 +96,20 @@ describe('StaticReflector', () => {
it('should provide context for errors reported by the collector', () => {
let SomeClass = host.findDeclaration('src/error-reporting', 'SomeClass');
expect(() => reflector.annotations(SomeClass)).toThrow(new Error('Error encountered resolving symbol values statically. A reasonable error message (position 12:33 in the original .ts file), resolving symbol ErrorSym in /tmp/src/error-references.d.ts, resolving symbol Link2 in /tmp/src/error-references.d.ts, resolving symbol Link1 in /tmp/src/error-references.d.ts, resolving symbol SomeClass in /tmp/src/error-reporting.d.ts, resolving symbol SomeClass in /tmp/src/error-reporting.d.ts'));
expect(() => reflector.annotations(SomeClass))
.toThrow(new Error(
'Error encountered resolving symbol values statically. A reasonable error message (position 12:33 in the original .ts file), resolving symbol ErrorSym in /tmp/src/error-references.d.ts, resolving symbol Link2 in /tmp/src/error-references.d.ts, resolving symbol Link1 in /tmp/src/error-references.d.ts, resolving symbol SomeClass in /tmp/src/error-reporting.d.ts, resolving symbol SomeClass in /tmp/src/error-reporting.d.ts'));
});
it('should simplify primitive into itself', () => {
expect(simplify(noContext, 1)).toBe(1);
expect(simplify(noContext, true)).toBe(true);
expect(simplify(noContext, "some value")).toBe("some value");
expect(simplify(noContext, 'some value')).toBe('some value');
});
it('should simplify an array into a copy of the array',
() => { expect(simplify(noContext, [1, 2, 3])).toEqual([1, 2, 3]); });
it('should simplify an array into a copy of the array', () => {
expect(simplify(noContext, [1, 2, 3])).toEqual([1, 2, 3]);
});
it('should simplify an object to a copy of the object', () => {
let expr = {a: 1, b: 2, c: 3};
@ -129,137 +117,180 @@ describe('StaticReflector', () => {
});
it('should simplify &&', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '&&', left: true, right: true}))).toBe(true);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '&&', left: true, right: false}))).toBe(false);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '&&', left: false, right: true}))).toBe(false);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '&&', left: false, right: false}))).toBe(false);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '&&', left: true, right: true})))
.toBe(true);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '&&', left: true, right: false})))
.toBe(false);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '&&', left: false, right: true})))
.toBe(false);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '&&', left: false, right: false})))
.toBe(false);
});
it('should simplify ||', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '||', left: true, right: true}))).toBe(true);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '||', left: true, right: false}))).toBe(true);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '||', left: false, right: true}))).toBe(true);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '||', left: false, right: false}))).toBe(false);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '||', left: true, right: true})))
.toBe(true);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '||', left: true, right: false})))
.toBe(true);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '||', left: false, right: true})))
.toBe(true);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '||', left: false, right: false})))
.toBe(false);
});
it('should simplify &', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '&', left: 0x22, right: 0x0F}))).toBe(0x22 & 0x0F);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '&', left: 0x22, right: 0xF0}))).toBe(0x22 & 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '&', left: 0x22, right: 0x0F})))
.toBe(0x22 & 0x0F);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '&', left: 0x22, right: 0xF0})))
.toBe(0x22 & 0xF0);
});
it('should simplify |', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '|', left: 0x22, right: 0x0F}))).toBe(0x22 | 0x0F);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '|', left: 0x22, right: 0xF0}))).toBe(0x22 | 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '|', left: 0x22, right: 0x0F})))
.toBe(0x22 | 0x0F);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '|', left: 0x22, right: 0xF0})))
.toBe(0x22 | 0xF0);
});
it('should simplify ^', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '|', left: 0x22, right: 0x0F}))).toBe(0x22 | 0x0F);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '|', left: 0x22, right: 0xF0}))).toBe(0x22 | 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '|', left: 0x22, right: 0x0F})))
.toBe(0x22 | 0x0F);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '|', left: 0x22, right: 0xF0})))
.toBe(0x22 | 0xF0);
});
it('should simplify ==', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '==', left: 0x22, right: 0x22}))).toBe(0x22 == 0x22);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '==', left: 0x22, right: 0xF0}))).toBe(0x22 == 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '==', left: 0x22, right: 0x22})))
.toBe(0x22 == 0x22);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '==', left: 0x22, right: 0xF0})))
.toBe(0x22 == 0xF0);
});
it('should simplify !=', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '!=', left: 0x22, right: 0x22}))).toBe(0x22 != 0x22);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '!=', left: 0x22, right: 0xF0}))).toBe(0x22 != 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '!=', left: 0x22, right: 0x22})))
.toBe(0x22 != 0x22);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '!=', left: 0x22, right: 0xF0})))
.toBe(0x22 != 0xF0);
});
it('should simplify ===', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '===', left: 0x22, right: 0x22}))).toBe(0x22 === 0x22);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '===', left: 0x22, right: 0xF0}))).toBe(0x22 === 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '===', left: 0x22, right: 0x22})))
.toBe(0x22 === 0x22);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '===', left: 0x22, right: 0xF0})))
.toBe(0x22 === 0xF0);
});
it('should simplify !==', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '!==', left: 0x22, right: 0x22}))).toBe(0x22 !== 0x22);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '!==', left: 0x22, right: 0xF0}))).toBe(0x22 !== 0xF0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '!==', left: 0x22, right: 0x22})))
.toBe(0x22 !== 0x22);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '!==', left: 0x22, right: 0xF0})))
.toBe(0x22 !== 0xF0);
});
it('should simplify >', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>', left: 1, right: 1}))).toBe(1 > 1);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>', left: 1, right: 0}))).toBe(1 > 0);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>', left: 0, right: 1}))).toBe(0 > 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>', left: 1, right: 1})))
.toBe(1 > 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>', left: 1, right: 0})))
.toBe(1 > 0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>', left: 0, right: 1})))
.toBe(0 > 1);
});
it('should simplify >=', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>=', left: 1, right: 1}))).toBe(1 >= 1);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>=', left: 1, right: 0}))).toBe(1 >= 0);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>=', left: 0, right: 1}))).toBe(0 >= 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>=', left: 1, right: 1})))
.toBe(1 >= 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>=', left: 1, right: 0})))
.toBe(1 >= 0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>=', left: 0, right: 1})))
.toBe(0 >= 1);
});
it('should simplify <=', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<=', left: 1, right: 1}))).toBe(1 <= 1);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<=', left: 1, right: 0}))).toBe(1 <= 0);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<=', left: 0, right: 1}))).toBe(0 <= 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<=', left: 1, right: 1})))
.toBe(1 <= 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<=', left: 1, right: 0})))
.toBe(1 <= 0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<=', left: 0, right: 1})))
.toBe(0 <= 1);
});
it('should simplify <', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<', left: 1, right: 1}))).toBe(1 < 1);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<', left: 1, right: 0}))).toBe(1 < 0);
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<', left: 0, right: 1}))).toBe(0 < 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<', left: 1, right: 1})))
.toBe(1 < 1);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<', left: 1, right: 0})))
.toBe(1 < 0);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<', left: 0, right: 1})))
.toBe(0 < 1);
});
it('should simplify <<', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '<<', left: 0x55, right: 2}))).toBe(0x55 << 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '<<', left: 0x55, right: 2})))
.toBe(0x55 << 2);
});
it('should simplify >>', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '>>', left: 0x55, right: 2}))).toBe(0x55 >> 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '>>', left: 0x55, right: 2})))
.toBe(0x55 >> 2);
});
it('should simplify +', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '+', left: 0x55, right: 2}))).toBe(0x55 + 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '+', left: 0x55, right: 2})))
.toBe(0x55 + 2);
});
it('should simplify -', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '-', left: 0x55, right: 2}))).toBe(0x55 - 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '-', left: 0x55, right: 2})))
.toBe(0x55 - 2);
});
it('should simplify *', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '*', left: 0x55, right: 2}))).toBe(0x55 * 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '*', left: 0x55, right: 2})))
.toBe(0x55 * 2);
});
it('should simplify /', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '/', left: 0x55, right: 2}))).toBe(0x55 / 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '/', left: 0x55, right: 2})))
.toBe(0x55 / 2);
});
it('should simplify %', () => {
expect(simplify(noContext, ({ __symbolic: 'binop', operator: '%', left: 0x55, right: 2}))).toBe(0x55 % 2);
expect(simplify(noContext, ({__symbolic: 'binop', operator: '%', left: 0x55, right: 2})))
.toBe(0x55 % 2);
});
it('should simplify prefix -', () => {
expect(simplify(noContext, ({ __symbolic: 'pre', operator: '-', operand: 2}))).toBe(-2);
expect(simplify(noContext, ({__symbolic: 'pre', operator: '-', operand: 2}))).toBe(-2);
});
it('should simplify prefix ~', () => {
expect(simplify(noContext, ({ __symbolic: 'pre', operator: '~', operand: 2}))).toBe(~2);
expect(simplify(noContext, ({__symbolic: 'pre', operator: '~', operand: 2}))).toBe(~2);
});
it('should simplify prefix !', () => {
expect(simplify(noContext, ({ __symbolic: 'pre', operator: '!', operand: true}))).toBe(!true);
expect(simplify(noContext, ({ __symbolic: 'pre', operator: '!', operand: false}))).toBe(!false);
expect(simplify(noContext, ({__symbolic: 'pre', operator: '!', operand: true}))).toBe(!true);
expect(simplify(noContext, ({__symbolic: 'pre', operator: '!', operand: false}))).toBe(!false);
});
it('should simplify an array index', () => {
expect(simplify(noContext, ({__symbolic: "index", expression: [1, 2, 3], index: 2}))).toBe(3);
expect(simplify(noContext, ({__symbolic: 'index', expression: [1, 2, 3], index: 2}))).toBe(3);
});
it('should simplify an object index', () => {
let expr = {__symbolic: "select", expression: {a: 1, b: 2, c: 3}, member: "b"};
let expr = {__symbolic: 'select', expression: {a: 1, b: 2, c: 3}, member: 'b'};
expect(simplify(noContext, expr)).toBe(2);
});
it('should simplify a module reference', () => {
expect(simplify(new StaticSymbol('/src/cases', ''),
({__symbolic: "reference", module: "./extern", name: "s"})))
.toEqual("s");
expect(simplify(
new StaticSymbol('/src/cases', ''),
({__symbolic: 'reference', module: './extern', name: 's'})))
.toEqual('s');
});
it('should simplify a non existing reference as a static symbol', () => {
expect(simplify(new StaticSymbol('/src/cases', ''),
({__symbolic: "reference", module: "./extern", name: "nonExisting"})))
expect(simplify(
new StaticSymbol('/src/cases', ''),
({__symbolic: 'reference', module: './extern', name: 'nonExisting'})))
.toEqual(host.getStaticSymbol('/src/extern.d.ts', 'nonExisting'));
});
});
@ -327,64 +358,64 @@ class MockReflectorHost implements StaticReflectorHost {
getMetadataFor(moduleId: string): any {
let data: {[key: string]: any} = {
'/tmp/angular2/src/common/forms-deprecated/directives.d.ts': [{
"__symbolic": "module",
"version": 1,
"metadata": {
"FORM_DIRECTIVES": [
'__symbolic': 'module',
'version': 1,
'metadata': {
'FORM_DIRECTIVES': [
{
"__symbolic": "reference",
"name": "NgFor",
"module": "angular2/src/common/directives/ng_for"
'__symbolic': 'reference',
'name': 'NgFor',
'module': 'angular2/src/common/directives/ng_for'
}
]
}
}],
'/tmp/angular2/src/common/directives/ng_for.d.ts': {
"__symbolic": "module",
"version": 1,
"metadata": {
"NgFor": {
"__symbolic": "class",
"decorators": [
'__symbolic': 'module',
'version': 1,
'metadata': {
'NgFor': {
'__symbolic': 'class',
'decorators': [
{
"__symbolic": "call",
"expression": {
"__symbolic": "reference",
"name": "Directive",
"module": "../../core/metadata"
'__symbolic': 'call',
'expression': {
'__symbolic': 'reference',
'name': 'Directive',
'module': '../../core/metadata'
},
"arguments": [
'arguments': [
{
"selector": "[ngFor][ngForOf]",
"inputs": ["ngForTrackBy", "ngForOf", "ngForTemplate"]
'selector': '[ngFor][ngForOf]',
'inputs': ['ngForTrackBy', 'ngForOf', 'ngForTemplate']
}
]
}
],
"members": {
"__ctor__": [
'members': {
'__ctor__': [
{
"__symbolic": "constructor",
"parameters": [
'__symbolic': 'constructor',
'parameters': [
{
"__symbolic": "reference",
"module": "../../core/linker/view_container_ref",
"name": "ViewContainerRef"
'__symbolic': 'reference',
'module': '../../core/linker/view_container_ref',
'name': 'ViewContainerRef'
},
{
"__symbolic": "reference",
"module": "../../core/linker/template_ref",
"name": "TemplateRef"
'__symbolic': 'reference',
'module': '../../core/linker/template_ref',
'name': 'TemplateRef'
},
{
"__symbolic": "reference",
"module": "../../core/change_detection/differs/iterable_differs",
"name": "IterableDiffers"
'__symbolic': 'reference',
'module': '../../core/change_detection/differs/iterable_differs',
'name': 'IterableDiffers'
},
{
"__symbolic": "reference",
"module": "../../core/change_detection/change_detector_ref",
"name": "ChangeDetectorRef"
'__symbolic': 'reference',
'module': '../../core/change_detection/change_detector_ref',
'name': 'ChangeDetectorRef'
}
]
}
@ -394,119 +425,119 @@ class MockReflectorHost implements StaticReflectorHost {
}
},
'/tmp/angular2/src/core/linker/view_container_ref.d.ts':
{version: 1, "metadata": {"ViewContainerRef": {"__symbolic": "class"}}},
{version: 1, 'metadata': {'ViewContainerRef': {'__symbolic': 'class'}}},
'/tmp/angular2/src/core/linker/template_ref.d.ts':
{version: 1, "module": "./template_ref", "metadata": {"TemplateRef": {"__symbolic": "class"}}},
{version: 1, 'module': './template_ref', 'metadata': {'TemplateRef': {'__symbolic': 'class'}}},
'/tmp/angular2/src/core/change_detection/differs/iterable_differs.d.ts':
{version: 1, "metadata": {"IterableDiffers": {"__symbolic": "class"}}},
{version: 1, 'metadata': {'IterableDiffers': {'__symbolic': 'class'}}},
'/tmp/angular2/src/core/change_detection/change_detector_ref.d.ts':
{version: 1, "metadata": {"ChangeDetectorRef": {"__symbolic": "class"}}},
{version: 1, 'metadata': {'ChangeDetectorRef': {'__symbolic': 'class'}}},
'/tmp/src/app/hero-detail.component.d.ts': {
"__symbolic": "module",
"version": 1,
"metadata": {
"HeroDetailComponent": {
"__symbolic": "class",
"decorators": [
'__symbolic': 'module',
'version': 1,
'metadata': {
'HeroDetailComponent': {
'__symbolic': 'class',
'decorators': [
{
"__symbolic": "call",
"expression": {
"__symbolic": "reference",
"name": "Component",
"module": "angular2/src/core/metadata"
'__symbolic': 'call',
'expression': {
'__symbolic': 'reference',
'name': 'Component',
'module': 'angular2/src/core/metadata'
},
"arguments": [
'arguments': [
{
"selector": "my-hero-detail",
"template":
"\n <div *ngIf=\"hero\">\n <h2>{{hero.name}} details!</h2>\n <div><label>id: </label>{{hero.id}}</div>\n <div>\n <label>name: </label>\n <input [(ngModel)]=\"hero.name\" placeholder=\"name\"/>\n </div>\n </div>\n",
"directives": [
'selector': 'my-hero-detail',
'template':
'\n <div *ngIf="hero">\n <h2>{{hero.name}} details!</h2>\n <div><label>id: </label>{{hero.id}}</div>\n <div>\n <label>name: </label>\n <input [(ngModel)]="hero.name" placeholder="name"/>\n </div>\n </div>\n',
'directives': [
{
"__symbolic": "reference",
"name": "FORM_DIRECTIVES",
"module": "angular2/src/common/forms-deprecated/directives"
'__symbolic': 'reference',
'name': 'FORM_DIRECTIVES',
'module': 'angular2/src/common/forms-deprecated/directives'
}
],
"animations": [{
"__symbolic": "call",
"expression": {
"__symbolic": "reference",
"name": "trigger",
"module": "angular2/src/core/animation/metadata"
'animations': [{
'__symbolic': 'call',
'expression': {
'__symbolic': 'reference',
'name': 'trigger',
'module': 'angular2/src/core/animation/metadata'
},
"arguments": [
"myAnimation",
[{ "__symbolic": "call",
"expression": {
"__symbolic": "reference",
"name": "state",
"module": "angular2/src/core/animation/metadata"
'arguments': [
'myAnimation',
[{ '__symbolic': 'call',
'expression': {
'__symbolic': 'reference',
'name': 'state',
'module': 'angular2/src/core/animation/metadata'
},
"arguments": [
"state1",
{ "__symbolic": "call",
"expression": {
"__symbolic": "reference",
"name": "style",
"module": "angular2/src/core/animation/metadata"
'arguments': [
'state1',
{ '__symbolic': 'call',
'expression': {
'__symbolic': 'reference',
'name': 'style',
'module': 'angular2/src/core/animation/metadata'
},
"arguments": [
{ "background":"white" }
'arguments': [
{ 'background':'white' }
]
}
]
}, {
"__symbolic": "call",
"expression": {
"__symbolic":"reference",
"name":"transition",
"module": "angular2/src/core/animation/metadata"
'__symbolic': 'call',
'expression': {
'__symbolic':'reference',
'name':'transition',
'module': 'angular2/src/core/animation/metadata'
},
"arguments": [
"* => *",
'arguments': [
'* => *',
{
"__symbolic":"call",
"expression":{
"__symbolic":"reference",
"name":"sequence",
"module": "angular2/src/core/animation/metadata"
'__symbolic':'call',
'expression':{
'__symbolic':'reference',
'name':'sequence',
'module': 'angular2/src/core/animation/metadata'
},
"arguments":[[{ "__symbolic": "call",
"expression": {
"__symbolic":"reference",
"name":"group",
"module": "angular2/src/core/animation/metadata"
'arguments':[[{ '__symbolic': 'call',
'expression': {
'__symbolic':'reference',
'name':'group',
'module': 'angular2/src/core/animation/metadata'
},
"arguments":[[{
"__symbolic": "call",
"expression": {
"__symbolic":"reference",
"name":"animate",
"module": "angular2/src/core/animation/metadata"
'arguments':[[{
'__symbolic': 'call',
'expression': {
'__symbolic':'reference',
'name':'animate',
'module': 'angular2/src/core/animation/metadata'
},
"arguments":[
"1s 0.5s",
{ "__symbolic": "call",
"expression": {
"__symbolic":"reference",
"name":"keyframes",
"module": "angular2/src/core/animation/metadata"
'arguments':[
'1s 0.5s',
{ '__symbolic': 'call',
'expression': {
'__symbolic':'reference',
'name':'keyframes',
'module': 'angular2/src/core/animation/metadata'
},
"arguments":[[{ "__symbolic": "call",
"expression": {
"__symbolic":"reference",
"name":"style",
"module": "angular2/src/core/animation/metadata"
'arguments':[[{ '__symbolic': 'call',
'expression': {
'__symbolic':'reference',
'name':'style',
'module': 'angular2/src/core/animation/metadata'
},
"arguments":[ { "background": "blue"} ]
'arguments':[ { 'background': 'blue'} ]
}, {
"__symbolic": "call",
"expression": {
"__symbolic":"reference",
"name":"style",
"module": "angular2/src/core/animation/metadata"
'__symbolic': 'call',
'expression': {
'__symbolic':'reference',
'name':'style',
'module': 'angular2/src/core/animation/metadata'
},
"arguments":[ { "background": "red"} ]
'arguments':[ { 'background': 'red'} ]
}]]
}
]
@ -520,17 +551,17 @@ class MockReflectorHost implements StaticReflectorHost {
}]
}]
}],
"members": {
"hero": [
'members': {
'hero': [
{
"__symbolic": "property",
"decorators": [
'__symbolic': 'property',
'decorators': [
{
"__symbolic": "call",
"expression": {
"__symbolic": "reference",
"name": "Input",
"module": "angular2/src/core/metadata"
'__symbolic': 'call',
'expression': {
'__symbolic': 'reference',
'name': 'Input',
'module': 'angular2/src/core/metadata'
}
}
]
@ -540,29 +571,29 @@ class MockReflectorHost implements StaticReflectorHost {
}
}
},
'/src/extern.d.ts': {"__symbolic": "module", "version": 1, metadata: {s: "s"}},
'/tmp/src/version-error.d.ts': {"__symbolic": "module", "version": 100, metadata: {e: "s"}},
'/src/extern.d.ts': {'__symbolic': 'module', 'version': 1, metadata: {s: 's'}},
'/tmp/src/version-error.d.ts': {'__symbolic': 'module', 'version': 100, metadata: {e: 's'}},
'/tmp/src/error-reporting.d.ts': {
__symbolic: "module",
__symbolic: 'module',
version: 1,
metadata: {
SomeClass: {
__symbolic: "class",
__symbolic: 'class',
decorators: [
{
__symbolic: "call",
__symbolic: 'call',
expression: {
__symbolic: "reference",
name: "Component",
module: "angular2/src/core/metadata"
__symbolic: 'reference',
name: 'Component',
module: 'angular2/src/core/metadata'
},
arguments: [
{
directives: [
{
__symbolic: "reference",
module: "src/error-references",
name: "Link1",
__symbolic: 'reference',
module: 'src/error-references',
name: 'Link1',
}
]
}
@ -573,22 +604,22 @@ class MockReflectorHost implements StaticReflectorHost {
}
},
'/tmp/src/error-references.d.ts': {
__symbolic: "module",
__symbolic: 'module',
version: 1,
metadata: {
Link1: {
__symbolic: "reference",
module: "src/error-references",
name: "Link2"
__symbolic: 'reference',
module: 'src/error-references',
name: 'Link2'
},
Link2: {
__symbolic: "reference",
module: "src/error-references",
name: "ErrorSym"
__symbolic: 'reference',
module: 'src/error-references',
name: 'ErrorSym'
},
ErrorSym: {
__symbolic: "error",
message: "A reasonable error message",
__symbolic: 'error',
message: 'A reasonable error message',
line: 12,
character: 33
}