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

@ -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();