refactor(ivy): ngcc - pass bundle
to DecorationAnalyzer
(#30591)
Rather than passing a number of individual arguments, we can just pass an `EntryPointBundle`, which already contains them. This is also a precursor to using more of the properties in the bundle. PR Close #30591
This commit is contained in:

committed by
Kara Erickson

parent
74f637f98d
commit
42036f4b79
@ -18,6 +18,7 @@ import {ClassDeclaration, ClassSymbol, Decorator} from '../../../src/ngtsc/refle
|
||||
import {LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from '../../../src/ngtsc/scope';
|
||||
import {CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence} from '../../../src/ngtsc/transform';
|
||||
import {NgccReflectionHost} from '../host/ngcc_host';
|
||||
import {EntryPointBundle} from '../packages/entry_point_bundle';
|
||||
import {isDefined} from '../utils';
|
||||
|
||||
export interface AnalyzedFile {
|
||||
@ -66,6 +67,12 @@ class NgccResourceLoader implements ResourceLoader {
|
||||
* This Analyzer will analyze the files that have decorated classes that need to be transformed.
|
||||
*/
|
||||
export class DecorationAnalyzer {
|
||||
private program = this.bundle.src.program;
|
||||
private options = this.bundle.src.options;
|
||||
private host = this.bundle.src.host;
|
||||
private typeChecker = this.bundle.src.program.getTypeChecker();
|
||||
private rootDirs = this.bundle.rootDirs;
|
||||
private isCore = this.bundle.isCore;
|
||||
resourceManager = new NgccResourceLoader(this.fs);
|
||||
metaRegistry = new LocalMetadataRegistry();
|
||||
dtsMetaReader = new DtsMetadataReader(this.typeChecker, this.reflectionHost);
|
||||
@ -112,10 +119,8 @@ export class DecorationAnalyzer {
|
||||
];
|
||||
|
||||
constructor(
|
||||
private fs: FileSystem, private program: ts.Program, private options: ts.CompilerOptions,
|
||||
private host: ts.CompilerHost, private typeChecker: ts.TypeChecker,
|
||||
private reflectionHost: NgccReflectionHost, private referencesRegistry: ReferencesRegistry,
|
||||
private rootDirs: AbsoluteFsPath[], private isCore: boolean) {}
|
||||
private fs: FileSystem, private bundle: EntryPointBundle,
|
||||
private reflectionHost: NgccReflectionHost, private referencesRegistry: ReferencesRegistry) {}
|
||||
|
||||
/**
|
||||
* Analyze a program to find all the decorated files should be transformed.
|
||||
|
@ -120,15 +120,13 @@ export class Transformer {
|
||||
}
|
||||
|
||||
analyzeProgram(reflectionHost: NgccReflectionHost, bundle: EntryPointBundle): ProgramAnalyses {
|
||||
const typeChecker = bundle.src.program.getTypeChecker();
|
||||
const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
|
||||
|
||||
const switchMarkerAnalyzer = new SwitchMarkerAnalyzer(reflectionHost);
|
||||
const switchMarkerAnalyses = switchMarkerAnalyzer.analyzeProgram(bundle.src.program);
|
||||
|
||||
const decorationAnalyzer = new DecorationAnalyzer(
|
||||
this.fs, bundle.src.program, bundle.src.options, bundle.src.host, typeChecker,
|
||||
reflectionHost, referencesRegistry, bundle.rootDirs, bundle.isCore);
|
||||
const decorationAnalyzer =
|
||||
new DecorationAnalyzer(this.fs, bundle, reflectionHost, referencesRegistry);
|
||||
const decorationAnalyses = decorationAnalyzer.analyzeProgram();
|
||||
|
||||
const moduleWithProvidersAnalyzer =
|
||||
|
Reference in New Issue
Block a user