refactor(compiler): move findDeclaration into the StaticReflector

Previously, this was part of the `AotCompilerHost`.
The `AotCompilerHost` is now also greatly simplified.
This commit is contained in:
Tobias Bosch
2016-11-15 08:49:23 -08:00
committed by Chuck Jazdzewski
parent 8f295287a2
commit e7025c9423
13 changed files with 612 additions and 704 deletions

View File

@ -19,18 +19,18 @@ import * as tsc from '@angular/tsc-wrapped';
import * as ts from 'typescript';
import {extractProgramSymbols} from './codegen';
import {ReflectorHost} from './reflector_host';
import {NgHost} from './ng_host';
export class Extractor {
constructor(
private options: tsc.AngularCompilerOptions, private program: ts.Program,
public host: ts.CompilerHost, private staticReflector: compiler.StaticReflector,
private messageBundle: compiler.MessageBundle, private reflectorHost: ReflectorHost,
private messageBundle: compiler.MessageBundle, private ngHost: NgHost,
private metadataResolver: compiler.CompileMetadataResolver) {}
extract(): Promise<compiler.MessageBundle> {
const programSymbols: compiler.StaticSymbol[] =
extractProgramSymbols(this.program, this.staticReflector, this.reflectorHost, this.options);
extractProgramSymbols(this.program, this.staticReflector, this.ngHost, this.options);
const {ngModules, files} = compiler.analyzeAndValidateNgModules(
programSymbols, {transitiveModules: true}, this.metadataResolver);
@ -65,12 +65,12 @@ export class Extractor {
static create(
options: tsc.AngularCompilerOptions, translationsFormat: string, program: ts.Program,
compilerHost: ts.CompilerHost, resourceLoader: compiler.ResourceLoader,
reflectorHost?: ReflectorHost): Extractor {
ngHost?: NgHost): Extractor {
const htmlParser = new compiler.I18NHtmlParser(new compiler.HtmlParser());
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
if (!reflectorHost) reflectorHost = new ReflectorHost(program, compilerHost, options);
const staticReflector = new compiler.StaticReflector(reflectorHost);
if (!ngHost) ngHost = new NgHost(program, compilerHost, options);
const staticReflector = new compiler.StaticReflector(ngHost);
compiler.StaticAndDynamicReflectionCapabilities.install(staticReflector);
const config = new compiler.CompilerConfig({
@ -92,6 +92,6 @@ export class Extractor {
const messageBundle = new compiler.MessageBundle(htmlParser, [], {});
return new Extractor(
options, program, compilerHost, staticReflector, messageBundle, reflectorHost, resolver);
options, program, compilerHost, staticReflector, messageBundle, ngHost, resolver);
}
}