88
99 /* tslint:disable:no-console */
1010
11- import { resolve } from 'path' ;
11+ import { resolve } from 'path' ;
1212import * as ts from 'typescript' ;
13- import { DecoratedClass } from './parser/parser' ;
14- import { FlatEsm2015PackageParser } from './parser/flat_esm2015_parser' ;
15- import { Esm2015ReflectionHost } from './host/esm2015_host' ;
13+ import { DecoratedClass } from './parser/parser' ;
14+ import { FlatEsm2015PackageParser } from './parser/flat_esm2015_parser' ;
15+ import { Esm2015ReflectionHost } from './host/esm2015_host' ;
16+ import { ComponentDecoratorHandler , DirectiveDecoratorHandler , InjectableDecoratorHandler , NgModuleDecoratorHandler , SelectorScopeRegistry } from '../../ngtsc/annotations' ;
17+ import { AnalyzedClass , Analyzer } from './analyzer' ;
1618
1719export function mainNgcc ( args : string [ ] ) : number {
1820 const rootPath = args [ 0 ] ;
@@ -30,6 +32,22 @@ export function mainNgcc(args: string[]): number {
3032 const decoratedClasses = parser . getDecoratedClasses ( entryPointFile ) ;
3133
3234 dumpDecoratedClasses ( decoratedClasses ) ;
35+
36+ const scopeRegistry = new SelectorScopeRegistry ( typeChecker , reflectionHost ) ;
37+ const handlers = [
38+ new ComponentDecoratorHandler ( typeChecker , reflectionHost , scopeRegistry ) ,
39+ new DirectiveDecoratorHandler ( typeChecker , reflectionHost , scopeRegistry ) ,
40+ new InjectableDecoratorHandler ( reflectionHost ) ,
41+ new NgModuleDecoratorHandler ( typeChecker , scopeRegistry ) ,
42+ ] ;
43+
44+ const analyzer = new Analyzer ( handlers ) ;
45+ const analyzedClasses = decoratedClasses
46+ . map ( decoratedClass => analyzer . analyze ( decoratedClass ) )
47+ . filter ( analysis => ! ! analysis ) as AnalyzedClass [ ] ;
48+
49+ dumpAnalysis ( analyzedClasses ) ;
50+
3351 return 0 ;
3452}
3553
@@ -44,4 +62,12 @@ function dumpDecoratedClasses(decoratedClasses: DecoratedClass[]) {
4462 }
4563 } ) ;
4664 } ) ;
65+ }
66+
67+ function dumpAnalysis ( analyzedClasses : AnalyzedClass [ ] ) {
68+ console . log ( 'Analyzed classes' ) ;
69+ analyzedClasses . forEach ( analyzedClass => {
70+ console . log ( `- ${ analyzedClass . clazz . name } ` ) ;
71+ console . log ( ` * ${ analyzedClass . analysis . name } :` , analyzedClass . analysis ) ;
72+ } ) ;
4773}
0 commit comments