refactor(ivy): move analysis side effects into a register phase (#34288)

Previously 'analyze' in the various `DecoratorHandler`s not only extracts
information from the decorators on the classes being analyzed, but also has
several side effects within the compiler:

* it can register metadata about the types involved in global metadata
  trackers.
* it can register information about which .ngfactory symbols are actually
  needed.

In this commit, these side-effects are moved into a new 'register' phase,
which runs after the 'analyze' step. Currently this is a no-op refactoring
as 'register' is always called directly after 'analyze'. In the future this
opens the door for re-use of prior analysis work (with only 'register' being
called, to apply the above side effects).

Also as part of this refactoring, the reification of NgModule scope
information into the incremental dependency graph is moved to the
`NgtscProgram` instead of the `TraitCompiler` (which now only manages trait
compilation and does not have other side effects).

PR Close #34288
This commit is contained in:
Alex Rickabaugh
2019-12-09 16:24:14 -08:00
committed by Kara Erickson
parent 252e3e9487
commit 50cdc0ac1b
14 changed files with 233 additions and 149 deletions

View File

@ -108,7 +108,9 @@ export class DecorationAnalyzer {
new NgModuleDecoratorHandler(
this.reflectionHost, this.evaluator, this.fullMetaReader, this.fullRegistry,
this.scopeRegistry, this.referencesRegistry, this.isCore, /* routeAnalyzer */ null,
this.refEmitter, NOOP_DEFAULT_IMPORT_RECORDER, /* annotateForClosureCompiler */ false),
this.refEmitter,
/* factoryTracker */ null, NOOP_DEFAULT_IMPORT_RECORDER,
/* annotateForClosureCompiler */ false),
];
migrations: Migration[] = [
new UndecoratedParentMigration(),

View File

@ -80,7 +80,12 @@ export function analyzeDecorators(
if (diagnostics !== undefined) {
allDiagnostics.push(...diagnostics);
}
match.analysis = analysis !;
if (analysis !== undefined) {
match.analysis = analysis;
if (match.handler.register !== undefined) {
match.handler.register(declaration, analysis);
}
}
matches.push(match);
} catch (e) {
if (isFatalDiagnosticError(e)) {