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:

committed by
Chuck Jazdzewski

parent
912ca44979
commit
24099bdbd2
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user