refactor(ngcc): use bundle src to create reflection hosts (#34254)

Previously individual properties of the src bundle program were
passed to the reflection host constructors. But going forward,
more properties will be required. To prevent the signature getting
continually larger and more unwieldy, this change just passes the
whole src bundle to the constructor, allowing it to extract what it
needs.

PR Close #34254
This commit is contained in:
Pete Bacon Darwin 2019-12-18 14:03:04 +00:00 committed by Kara Erickson
parent dfecca29da
commit 0b837e2f0d
24 changed files with 1428 additions and 1459 deletions

View File

@ -19,10 +19,12 @@ import {NgccClassSymbol} from './ngcc_host';
export class CommonJsReflectionHost extends Esm5ReflectionHost {
protected commonJsExports = new Map<ts.SourceFile, Map<string, Declaration>|null>();
protected topLevelHelperCalls = new Map<string, Map<ts.SourceFile, ts.CallExpression[]>>();
constructor(
logger: Logger, isCore: boolean, protected program: ts.Program,
protected compilerHost: ts.CompilerHost, dts?: BundleProgram|null) {
super(logger, isCore, program.getTypeChecker(), dts);
protected program: ts.Program;
protected compilerHost: ts.CompilerHost;
constructor(logger: Logger, isCore: boolean, src: BundleProgram, dts?: BundleProgram|null) {
super(logger, isCore, src, dts);
this.program = src.program;
this.compilerHost = src.host;
}
getImportOfIdentifier(id: ts.Identifier): Import|null {

View File

@ -83,9 +83,9 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
protected decoratorCache = new Map<ClassDeclaration, DecoratorInfo>();
constructor(
protected logger: Logger, protected isCore: boolean, checker: ts.TypeChecker,
protected logger: Logger, protected isCore: boolean, src: BundleProgram,
dts?: BundleProgram|null) {
super(checker);
super(src.program.getTypeChecker());
this.dtsDeclarationMap =
dts && this.computeDtsDeclarationMap(dts.path, dts.program, dts.package) || null;
}

View File

@ -18,10 +18,12 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
protected umdModules = new Map<ts.SourceFile, UmdModule|null>();
protected umdExports = new Map<ts.SourceFile, Map<string, Declaration>|null>();
protected umdImportPaths = new Map<ts.ParameterDeclaration, string|null>();
constructor(
logger: Logger, isCore: boolean, protected program: ts.Program,
protected compilerHost: ts.CompilerHost, dts?: BundleProgram|null) {
super(logger, isCore, program.getTypeChecker(), dts);
protected program: ts.Program;
protected compilerHost: ts.CompilerHost;
constructor(logger: Logger, isCore: boolean, src: BundleProgram, dts?: BundleProgram|null) {
super(logger, isCore, src, dts);
this.program = src.program;
this.compilerHost = src.host;
}
getImportOfIdentifier(id: ts.Identifier): Import|null {

View File

@ -100,18 +100,15 @@ export class Transformer {
}
getHost(bundle: EntryPointBundle): NgccReflectionHost {
const typeChecker = bundle.src.program.getTypeChecker();
switch (bundle.format) {
case 'esm2015':
return new Esm2015ReflectionHost(this.logger, bundle.isCore, typeChecker, bundle.dts);
return new Esm2015ReflectionHost(this.logger, bundle.isCore, bundle.src, bundle.dts);
case 'esm5':
return new Esm5ReflectionHost(this.logger, bundle.isCore, typeChecker, bundle.dts);
return new Esm5ReflectionHost(this.logger, bundle.isCore, bundle.src, bundle.dts);
case 'umd':
return new UmdReflectionHost(
this.logger, bundle.isCore, bundle.src.program, bundle.src.host, bundle.dts);
return new UmdReflectionHost(this.logger, bundle.isCore, bundle.src, bundle.dts);
case 'commonjs':
return new CommonJsReflectionHost(
this.logger, bundle.isCore, bundle.src.program, bundle.src.host, bundle.dts);
return new CommonJsReflectionHost(this.logger, bundle.isCore, bundle.src, bundle.dts);
default:
throw new Error(`Reflection host for "${bundle.format}" not yet implemented.`);
}

View File

@ -110,8 +110,7 @@ runInEachFileSystem(() => {
const bundle = makeTestEntryPointBundle('test-package', 'esm2015', false, rootFiles);
program = bundle.src.program;
const reflectionHost =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const reflectionHost = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
diagnosticLogs = [];
const analyzer = new DecorationAnalyzer(

View File

@ -334,8 +334,7 @@ runInEachFileSystem(() => {
getRootFiles(TEST_DTS_PROGRAM));
program = bundle.src.program;
dtsProgram = bundle.dts !;
const host = new Esm2015ReflectionHost(
new MockLogger(), false, program.getTypeChecker(), dtsProgram);
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src, dtsProgram);
referencesRegistry = new NgccReferencesRegistry(host);
const processDts = true;
@ -538,8 +537,7 @@ runInEachFileSystem(() => {
getRootFiles(TEST_DTS_PROGRAM));
const program = bundle.src.program;
const dtsProgram = bundle.dts !;
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker(), dtsProgram);
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src, dtsProgram);
const referencesRegistry = new NgccReferencesRegistry(host);
const processDts = true;
@ -569,8 +567,7 @@ runInEachFileSystem(() => {
const bundle =
makeTestEntryPointBundle('test-package', 'esm2015', false, getRootFiles(TEST_PROGRAM));
const program = bundle.src.program;
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker(), null);
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src, null);
const referencesRegistry = new NgccReferencesRegistry(host);
const processDts = false; // Emulate the scenario where typings have already been processed

View File

@ -235,12 +235,12 @@ runInEachFileSystem(() => {
function setup(jsProgram: TestFile[], dtsProgram: TestFile[]) {
loadTestFiles(jsProgram);
loadTestFiles(dtsProgram);
const {src: {program}, dts} = makeTestEntryPointBundle(
const {src, dts} = makeTestEntryPointBundle(
'test-package', 'esm2015', false, getRootFiles(jsProgram), getRootFiles(dtsProgram));
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker(), dts);
const host = new Esm2015ReflectionHost(new MockLogger(), false, src, dts);
const referencesRegistry = new NgccReferencesRegistry(host);
const analyzer = new PrivateDeclarationsAnalyzer(host, referencesRegistry);
return {program, referencesRegistry, analyzer};
return {program: src.program, referencesRegistry, analyzer};
}
/**

View File

@ -74,7 +74,7 @@ runInEachFileSystem(() => {
const bundle = makeTestEntryPointBundle(
'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]);
const program = bundle.src.program;
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.package);
const analysis = analyzer.analyzeProgram(program);
@ -105,7 +105,7 @@ runInEachFileSystem(() => {
const bundle = makeTestEntryPointBundle(
'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]);
const program = bundle.src.program;
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.package);
const analysis = analyzer.analyzeProgram(program);

View File

@ -85,10 +85,11 @@ exports.AliasedDirective$1 = AliasedDirective$1;
it('should find the decorators on a class at the top level', () => {
loadFakeCore(getFileSystem());
loadTestFiles([TOPLEVEL_DECORATORS_FILE]);
const {program, host: compilerHost} = makeTestBundleProgram(TOPLEVEL_DECORATORS_FILE.name);
const host = new CommonJsReflectionHost(new MockLogger(), false, program, compilerHost);
const bundle = makeTestBundleProgram(TOPLEVEL_DECORATORS_FILE.name);
const host = new CommonJsReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, TOPLEVEL_DECORATORS_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
bundle.program, TOPLEVEL_DECORATORS_FILE.name, 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
expect(decorators.length).toEqual(1);
@ -105,10 +106,10 @@ exports.AliasedDirective$1 = AliasedDirective$1;
it('should find the decorators on an aliased class at the top level', () => {
loadFakeCore(getFileSystem());
loadTestFiles([TOPLEVEL_DECORATORS_FILE]);
const {program, host: compilerHost} = makeTestBundleProgram(TOPLEVEL_DECORATORS_FILE.name);
const host = new CommonJsReflectionHost(new MockLogger(), false, program, compilerHost);
const bundle = makeTestBundleProgram(TOPLEVEL_DECORATORS_FILE.name);
const host = new CommonJsReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, TOPLEVEL_DECORATORS_FILE.name, 'AliasedDirective$1',
bundle.program, TOPLEVEL_DECORATORS_FILE.name, 'AliasedDirective$1',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;

File diff suppressed because it is too large Load Diff

View File

@ -163,11 +163,11 @@ runInEachFileSystem(() => {
describe('getDecoratorsOfDeclaration()', () => {
it('should find the decorators on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
expect(decorators).toBeDefined();
@ -184,11 +184,10 @@ runInEachFileSystem(() => {
it('should find the decorators on a class when mixing `ctorParameters` and `__decorate`',
() => {
const {program} = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -205,12 +204,11 @@ runInEachFileSystem(() => {
});
it('should support decorators being used inside @angular/core', () => {
const {program} =
const bundle =
makeTestBundleProgram(_('/node_modules/@angular/core/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), true, program.getTypeChecker());
const host = new Esm2015ReflectionHost(new MockLogger(), true, bundle);
const classNode = getDeclaration(
program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
bundle.program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -229,11 +227,11 @@ runInEachFileSystem(() => {
describe('getMembersOfClass()', () => {
it('should find decorated members on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const input1 = members.find(member => member.name === 'input1') !;
@ -249,11 +247,10 @@ runInEachFileSystem(() => {
it('should find decorated members on a class when mixing `ctorParameters` and `__decorate`',
() => {
const {program} = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
@ -264,11 +261,11 @@ runInEachFileSystem(() => {
});
it('should find non decorated properties on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const instanceProperty = members.find(member => member.name === 'instanceProperty') !;
@ -279,11 +276,11 @@ runInEachFileSystem(() => {
});
it('should find static methods on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const staticMethod = members.find(member => member.name === 'staticMethod') !;
@ -293,11 +290,11 @@ runInEachFileSystem(() => {
});
it('should find static properties on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const staticProperty = members.find(member => member.name === 'staticProperty') !;
@ -309,11 +306,11 @@ runInEachFileSystem(() => {
it('should find static properties on a class that has an intermediate variable assignment',
() => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/ngmodule.js'), 'HttpClientXsrfModule', isNamedVariableDeclaration);
bundle.program, _('/ngmodule.js'), 'HttpClientXsrfModule',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const staticProperty = members.find(member => member.name === 'staticProperty') !;
@ -324,12 +321,11 @@ runInEachFileSystem(() => {
});
it('should support decorators being used inside @angular/core', () => {
const {program} =
const bundle =
makeTestBundleProgram(_('/node_modules/@angular/core/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), true, program.getTypeChecker());
const host = new Esm2015ReflectionHost(new MockLogger(), true, bundle);
const classNode = getDeclaration(
program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
bundle.program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
@ -342,11 +338,11 @@ runInEachFileSystem(() => {
describe('getConstructorParameters', () => {
it('should find the decorated constructor parameters', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const parameters = host.getConstructorParameters(classNode);
expect(parameters).toBeDefined();
@ -362,11 +358,10 @@ runInEachFileSystem(() => {
it('should find the decorated constructor parameters when mixing `ctorParameters` and `__decorate`',
() => {
const {program} = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
isNamedVariableDeclaration);
const parameters = host.getConstructorParameters(classNode);
@ -390,11 +385,11 @@ runInEachFileSystem(() => {
describe('getDeclarationOfIdentifier', () => {
it('should return the declaration of a locally defined identifier', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const ctrDecorators = host.getConstructorParameters(classNode) !;
const identifierOfViewContainerRef = (ctrDecorators[0].typeValueReference !as{
local: true,
@ -403,7 +398,7 @@ runInEachFileSystem(() => {
}).expression;
const expectedDeclarationNode = getDeclaration(
program, _('/some_directive.js'), 'ViewContainerRef', ts.isClassDeclaration);
bundle.program, _('/some_directive.js'), 'ViewContainerRef', ts.isClassDeclaration);
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfViewContainerRef);
expect(actualDeclaration).not.toBe(null);
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
@ -411,11 +406,11 @@ runInEachFileSystem(() => {
});
it('should return the declaration of an externally defined identifier', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const classDecorators = host.getDecoratorsOfDeclaration(classNode) !;
const decoratorNode = classDecorators[0].node !;
const identifierOfDirective =
@ -424,7 +419,7 @@ runInEachFileSystem(() => {
null;
const expectedDeclarationNode = getDeclaration(
program, _('/node_modules/@angular/core/index.d.ts'), 'Directive',
bundle.program, _('/node_modules/@angular/core/index.d.ts'), 'Directive',
isNamedVariableDeclaration);
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
expect(actualDeclaration).not.toBe(null);
@ -435,11 +430,10 @@ runInEachFileSystem(() => {
describe('getVariableValue', () => {
it('should find the "actual" declaration of an aliased variable identifier', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const ngModuleRef = findVariableDeclaration(
getSourceFileOrError(program, _('/ngmodule.js')), 'HttpClientXsrfModule_1');
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'HttpClientXsrfModule_1');
const value = host.getVariableValue(ngModuleRef !);
expect(value).not.toBe(null);
@ -451,21 +445,19 @@ runInEachFileSystem(() => {
});
it('should return null if the variable has no assignment', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const missingValue = findVariableDeclaration(
getSourceFileOrError(program, _('/ngmodule.js')), 'missingValue');
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'missingValue');
const value = host.getVariableValue(missingValue !);
expect(value).toBe(null);
});
it('should return null if the variable is not assigned from a call to __decorate', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const nonDecoratedVar = findVariableDeclaration(
getSourceFileOrError(program, _('/ngmodule.js')), 'nonDecoratedVar');
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'nonDecoratedVar');
const value = host.getVariableValue(nonDecoratedVar !);
expect(value).toBe(null);
});
@ -473,11 +465,10 @@ runInEachFileSystem(() => {
describe('getEndOfClass()', () => {
it('should return the last statement related to the class', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
const classSymbol =
host.findClassSymbols(program.getSourceFile(_('/ngmodule.js')) !)[0];
host.findClassSymbols(bundle.program.getSourceFile(_('/ngmodule.js')) !)[0];
const endOfClass = host.getEndOfClass(classSymbol);
expect(endOfClass.getText())
.toMatch(

File diff suppressed because it is too large Load Diff

View File

@ -222,10 +222,11 @@ export { AliasedDirective$1 };
describe('getDecoratorsOfDeclaration()', () => {
it('should find the decorators on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
expect(decorators).toBeDefined();
@ -242,10 +243,10 @@ export { AliasedDirective$1 };
});
it('should find the decorators on a minified class', () => {
const {program} = makeTestBundleProgram(_('/some_minified_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_minified_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_minified_directive.js'), 'SomeDirective',
bundle.program, _('/some_minified_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -263,10 +264,10 @@ export { AliasedDirective$1 };
});
it('should find the decorators on an aliased class', () => {
const {program} = makeTestBundleProgram(_('/some_aliased_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_aliased_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_aliased_directive.js'), 'AliasedDirective$1',
bundle.program, _('/some_aliased_directive.js'), 'AliasedDirective$1',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -284,11 +285,10 @@ export { AliasedDirective$1 };
it('should find the decorators on a class when mixing `ctorParameters` and `__decorate`',
() => {
const {program} = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host =
new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -305,11 +305,11 @@ export { AliasedDirective$1 };
});
it('should support decorators being used inside @angular/core', () => {
const {program} =
const bundle =
makeTestBundleProgram(_('/node_modules/@angular/core/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), true, program.getTypeChecker());
const host = new Esm5ReflectionHost(new MockLogger(), true, bundle);
const classNode = getDeclaration(
program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
bundle.program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -328,10 +328,10 @@ export { AliasedDirective$1 };
describe('getClassSymbol()', () => {
it('should find a class that has been minified', () => {
const {program} = makeTestBundleProgram(_('/some_minified_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_minified_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_minified_directive.js'), 'SomeDirective',
bundle.program, _('/some_minified_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const innerNode =
getIifeBody(classNode) !.statements.find(isNamedFunctionDeclaration) !;
@ -345,10 +345,11 @@ export { AliasedDirective$1 };
describe('getMembersOfClass()', () => {
it('should find decorated members on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const input1 = members.find(member => member.name === 'input1') !;
@ -364,11 +365,10 @@ export { AliasedDirective$1 };
it('should find decorated members on a class when mixing `ctorParameters` and `__decorate`',
() => {
const {program} = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host =
new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
@ -379,10 +379,11 @@ export { AliasedDirective$1 };
});
it('should find non decorated properties on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const instanceProperty = members.find(member => member.name === 'instanceProperty') !;
@ -393,10 +394,11 @@ export { AliasedDirective$1 };
});
it('should find static methods on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const staticMethod = members.find(member => member.name === 'staticMethod') !;
@ -406,10 +408,11 @@ export { AliasedDirective$1 };
});
it('should find static properties on a class', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const staticProperty = members.find(member => member.name === 'staticProperty') !;
@ -420,11 +423,11 @@ export { AliasedDirective$1 };
});
it('should support decorators being used inside @angular/core', () => {
const {program} =
const bundle =
makeTestBundleProgram(_('/node_modules/@angular/core/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), true, program.getTypeChecker());
const host = new Esm5ReflectionHost(new MockLogger(), true, bundle);
const classNode = getDeclaration(
program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
bundle.program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
@ -436,10 +439,11 @@ export { AliasedDirective$1 };
});
describe('getConstructorParameters', () => {
it('should find the decorated constructor parameters', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const parameters = host.getConstructorParameters(classNode);
expect(parameters).toBeDefined();
@ -455,11 +459,10 @@ export { AliasedDirective$1 };
it('should find the decorated constructor parameters when mixing `ctorParameters` and `__decorate`',
() => {
const {program} = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host =
new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive_ctor_parameters.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
isNamedVariableDeclaration);
const parameters = host.getConstructorParameters(classNode);
@ -476,11 +479,11 @@ export { AliasedDirective$1 };
describe('(returned parameters `decorators`)', () => {
it('should have import information on decorators', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host =
new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const parameters = host.getConstructorParameters(classNode);
const decorators = parameters ![2].decorators !;
@ -492,15 +495,15 @@ export { AliasedDirective$1 };
describe('findClassSymbols()', () => {
it('should return an array of all classes in the given source file', () => {
const {program} = makeTestBundleProgram(_('/index.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/index.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const ngModuleFile = getSourceFileOrError(program, _('/ngmodule.js'));
const ngModuleFile = getSourceFileOrError(bundle.program, _('/ngmodule.js'));
const ngModuleClasses = host.findClassSymbols(ngModuleFile);
expect(ngModuleClasses.length).toEqual(1);
expect(ngModuleClasses[0].name).toBe('HttpClientXsrfModule');
const someDirectiveFile = getSourceFileOrError(program, _('/some_directive.js'));
const someDirectiveFile = getSourceFileOrError(bundle.program, _('/some_directive.js'));
const someDirectiveClasses = host.findClassSymbols(someDirectiveFile);
expect(someDirectiveClasses.length).toEqual(3);
expect(someDirectiveClasses[0].name).toBe('ViewContainerRef');
@ -511,17 +514,17 @@ export { AliasedDirective$1 };
describe('getDecoratorsOfSymbol()', () => {
it('should return decorators of class symbol', () => {
const {program} = makeTestBundleProgram(_('/index.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/index.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const ngModuleFile = getSourceFileOrError(program, _('/ngmodule.js'));
const ngModuleFile = getSourceFileOrError(bundle.program, _('/ngmodule.js'));
const ngModuleClasses = host.findClassSymbols(ngModuleFile);
const ngModuleDecorators = ngModuleClasses.map(s => host.getDecoratorsOfSymbol(s));
expect(ngModuleClasses.length).toEqual(1);
expect(ngModuleDecorators[0] !.map(d => d.name)).toEqual(['NgModule']);
const someDirectiveFile = getSourceFileOrError(program, _('/some_directive.js'));
const someDirectiveFile = getSourceFileOrError(bundle.program, _('/some_directive.js'));
const someDirectiveClasses = host.findClassSymbols(someDirectiveFile);
const someDirectiveDecorators =
someDirectiveClasses.map(s => host.getDecoratorsOfSymbol(s));
@ -535,10 +538,11 @@ export { AliasedDirective$1 };
describe('getDeclarationOfIdentifier', () => {
it('should return the declaration of a locally defined identifier', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const ctrDecorators = host.getConstructorParameters(classNode) !;
const identifierOfViewContainerRef = (ctrDecorators[0].typeValueReference !as{
local: true,
@ -547,7 +551,8 @@ export { AliasedDirective$1 };
}).expression;
const expectedDeclarationNode = getDeclaration(
program, _('/some_directive.js'), 'ViewContainerRef', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'ViewContainerRef',
isNamedVariableDeclaration);
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfViewContainerRef);
expect(actualDeclaration).not.toBe(null);
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
@ -555,10 +560,11 @@ export { AliasedDirective$1 };
});
it('should return the declaration of an externally defined identifier', () => {
const {program} = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/some_directive.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
bundle.program, _('/some_directive.js'), 'SomeDirective',
isNamedVariableDeclaration);
const classDecorators = host.getDecoratorsOfDeclaration(classNode) !;
const decoratorNode = classDecorators[0].node !;
@ -568,7 +574,7 @@ export { AliasedDirective$1 };
null;
const expectedDeclarationNode = getDeclaration(
program, _('/node_modules/@angular/core/index.d.ts'), 'Directive',
bundle.program, _('/node_modules/@angular/core/index.d.ts'), 'Directive',
isNamedVariableDeclaration);
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
expect(actualDeclaration).not.toBe(null);
@ -577,10 +583,10 @@ export { AliasedDirective$1 };
});
it('should find the "actual" declaration of an aliased variable identifier', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const ngModuleRef = findIdentifier(
getSourceFileOrError(program, _('/ngmodule.js')), 'HttpClientXsrfModule_1',
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'HttpClientXsrfModule_1',
isNgModulePropertyAssignment);
const declaration = host.getDeclarationOfIdentifier(ngModuleRef !);
@ -590,10 +596,10 @@ export { AliasedDirective$1 };
});
describe('getVariableValue', () => {
it('should find the "actual" declaration of an aliased variable identifier', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const ngModuleRef = findVariableDeclaration(
getSourceFileOrError(program, _('/ngmodule.js')), 'HttpClientXsrfModule_1');
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'HttpClientXsrfModule_1');
const value = host.getVariableValue(ngModuleRef !);
expect(value).not.toBe(null);
@ -605,19 +611,19 @@ export { AliasedDirective$1 };
});
it('should return undefined if the variable has no assignment', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const missingValue = findVariableDeclaration(
getSourceFileOrError(program, _('/ngmodule.js')), 'missingValue');
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'missingValue');
const value = host.getVariableValue(missingValue !);
expect(value).toBe(null);
});
it('should return null if the variable is not assigned from a call to __decorate', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const nonDecoratedVar = findVariableDeclaration(
getSourceFileOrError(program, _('/ngmodule.js')), 'nonDecoratedVar');
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'nonDecoratedVar');
const value = host.getVariableValue(nonDecoratedVar !);
expect(value).toBe(null);
});
@ -625,10 +631,10 @@ export { AliasedDirective$1 };
describe('getEndOfClass()', () => {
it('should return the last statement related to the class', () => {
const {program} = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
const classSymbol =
host.findClassSymbols(program.getSourceFile(_('/ngmodule.js')) !)[0];
host.findClassSymbols(bundle.program.getSourceFile(_('/ngmodule.js')) !)[0];
const endOfClass = host.getEndOfClass(classSymbol);
expect(endOfClass.getText())
.toMatch(

File diff suppressed because it is too large Load Diff

View File

@ -77,10 +77,10 @@ runInEachFileSystem(() => {
describe('getDecoratorsOfDeclaration()', () => {
it('should find the decorators on a class', () => {
loadTestFiles([SOME_DIRECTIVE_FILE]);
const {program, host: compilerHost} = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, program, compilerHost);
const bundle = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
bundle.program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
expect(decorators).toBeDefined();
@ -97,10 +97,11 @@ runInEachFileSystem(() => {
it('should find the decorators on an aliased class', () => {
loadTestFiles([SOME_DIRECTIVE_FILE]);
const {program, host: compilerHost} = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, program, compilerHost);
const bundle = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, SOME_DIRECTIVE_FILE.name, 'AliasedDirective$1', isNamedVariableDeclaration);
bundle.program, SOME_DIRECTIVE_FILE.name, 'AliasedDirective$1',
isNamedVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
expect(decorators).toBeDefined();
@ -119,10 +120,10 @@ runInEachFileSystem(() => {
describe('getMembersOfClass()', () => {
it('should find decorated members on a class', () => {
loadTestFiles([SOME_DIRECTIVE_FILE]);
const {program, host: compilerHost} = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, program, compilerHost);
const bundle = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
bundle.program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
const members = host.getMembersOfClass(classNode);
const input1 = members.find(member => member.name === 'input1') !;
@ -139,10 +140,11 @@ runInEachFileSystem(() => {
describe('getConstructorParameters', () => {
it('should find the decorated constructor parameters', () => {
loadTestFiles([SOME_DIRECTIVE_FILE]);
const {program, host: compilerHost} = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, program, compilerHost);
const bundle = makeTestBundleProgram(SOME_DIRECTIVE_FILE.name);
const host = new UmdReflectionHost(new MockLogger(), false, bundle);
const classNode = getDeclaration(
program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
bundle.program, SOME_DIRECTIVE_FILE.name, 'SomeDirective',
isNamedVariableDeclaration);
const parameters = host.getConstructorParameters(classNode);
expect(parameters).toBeDefined();

File diff suppressed because it is too large Load Diff

View File

@ -559,8 +559,7 @@ runInEachFileSystem(() => {
const bundle = makeTestEntryPointBundle('test-package', 'esm2015', false, rootFiles);
const program = bundle.src.program;
const reflectionHost =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const reflectionHost = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
const analyzer = new DecorationAnalyzer(
getFileSystem(), bundle, reflectionHost, referencesRegistry, error => errors.push(error));

View File

@ -246,8 +246,7 @@ runInEachFileSystem(() => {
const bundle = makeTestEntryPointBundle('test-package', 'esm2015', false, rootFiles);
const program = bundle.src.program;
const reflectionHost =
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
const reflectionHost = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
const analyzer = new DecorationAnalyzer(
getFileSystem(), bundle, reflectionHost, referencesRegistry, error => errors.push(error));

View File

@ -151,8 +151,7 @@ exports.D = D;
const fs = getFileSystem();
const logger = new MockLogger();
const bundle = makeTestEntryPointBundle('test-package', 'commonjs', false, [file.name]);
const typeChecker = bundle.src.program.getTypeChecker();
const host = new CommonJsReflectionHost(logger, false, bundle.src.program, bundle.src.host);
const host = new CommonJsReflectionHost(logger, false, bundle.src);
const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();

View File

@ -70,8 +70,7 @@ function createTestRenderer(
const isCore = packageName === '@angular/core';
const bundle = makeTestEntryPointBundle(
'test-package', 'esm2015', isCore, getRootFiles(files), dtsFiles && getRootFiles(dtsFiles));
const typeChecker = bundle.src.program.getTypeChecker();
const host = new Esm2015ReflectionHost(logger, isCore, typeChecker, bundle.dts);
const host = new Esm2015ReflectionHost(logger, isCore, bundle.src, bundle.dts);
const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();

View File

@ -28,8 +28,7 @@ function setup(file: {name: AbsoluteFsPath, contents: string}) {
const fs = getFileSystem();
const logger = new MockLogger();
const bundle = makeTestEntryPointBundle('test-package', 'esm5', false, [file.name]);
const typeChecker = bundle.src.program.getTypeChecker();
const host = new Esm5ReflectionHost(logger, false, typeChecker);
const host = new Esm5ReflectionHost(logger, false, bundle.src);
const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();

View File

@ -33,8 +33,7 @@ function setup(files: TestFile[], dtsFiles?: TestFile[]) {
const logger = new MockLogger();
const bundle = makeTestEntryPointBundle(
'test-package', 'esm2015', false, getRootFiles(files), dtsFiles && getRootFiles(dtsFiles)) !;
const typeChecker = bundle.src.program.getTypeChecker();
const host = new Esm2015ReflectionHost(logger, false, typeChecker, bundle.dts);
const host = new Esm2015ReflectionHost(logger, false, bundle.src, bundle.dts);
const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();

View File

@ -83,9 +83,8 @@ function createTestRenderer(
const isCore = packageName === '@angular/core';
const bundle = makeTestEntryPointBundle(
'test-package', 'esm5', isCore, getRootFiles(files), dtsFiles && getRootFiles(dtsFiles));
const typeChecker = bundle.src.program.getTypeChecker();
const host = isEs5 ? new Esm5ReflectionHost(logger, isCore, typeChecker, bundle.dts) :
new Esm2015ReflectionHost(logger, isCore, typeChecker, bundle.dts);
const host = isEs5 ? new Esm5ReflectionHost(logger, isCore, bundle.src, bundle.dts) :
new Esm2015ReflectionHost(logger, isCore, bundle.src, bundle.dts);
const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();

View File

@ -28,7 +28,7 @@ function setup(file: TestFile) {
const logger = new MockLogger();
const bundle = makeTestEntryPointBundle('test-package', 'esm5', false, [file.name]);
const src = bundle.src;
const host = new UmdReflectionHost(logger, false, src.program, src.host);
const host = new UmdReflectionHost(logger, false, src);
const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();