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:

committed by
Kara Erickson

parent
dfecca29da
commit
0b837e2f0d
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user