refactor(ivy): ngcc - recombine flat and non-flat `Esm2015ReflectionHost` (#26403)

Going forward we need to be able to do the same work on both
flat and non-flat module formats (such as computing arity and
transforming .d.ts files)

PR Close #26403
This commit is contained in:
Pete Bacon Darwin 2018-10-10 14:17:32 +01:00 committed by Kara Erickson
parent 81acbad058
commit bec4ca0c73
13 changed files with 2217 additions and 2346 deletions

View File

@ -17,13 +17,13 @@ export type SwitchMarkerAnalyses = Map<ts.SourceFile, SwitchMarkerAnalysis>;
export const SwitchMarkerAnalyses = Map; export const SwitchMarkerAnalyses = Map;
/** /**
* This Analyzer will analyse the files that have an NGCC switch marker in them * This Analyzer will analyse the files that have an R3 switch marker in them
* that will be replaced. * that will be replaced.
*/ */
export class SwitchMarkerAnalyzer { export class SwitchMarkerAnalyzer {
constructor(private host: NgccReflectionHost) {} constructor(private host: NgccReflectionHost) {}
/** /**
* Analyze the files in the program to identify declarations that contain NGCC * Analyze the files in the program to identify declarations that contain R3
* switch markers. * switch markers.
* @param program The program to analyze. * @param program The program to analyze.
* @return A map of source files to analysis objects. The map will contain only the * @return A map of source files to analysis objects. The map will contain only the

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ import {getNameText, getOriginalSymbol, isDefined} from '../utils';
import {DecoratedClass} from './decorated_class'; import {DecoratedClass} from './decorated_class';
import {DecoratedFile} from './decorated_file'; import {DecoratedFile} from './decorated_file';
import {Fesm2015ReflectionHost, ParamInfo, getPropertyValueFromSymbol, isAssignmentStatement} from './fesm2015_host'; import {Esm2015ReflectionHost, ParamInfo, getPropertyValueFromSymbol, isAssignmentStatement} from './esm2015_host';
/** /**
@ -34,7 +34,7 @@ import {Fesm2015ReflectionHost, ParamInfo, getPropertyValueFromSymbol, isAssignm
* a static method called `ctorParameters`. * a static method called `ctorParameters`.
* *
*/ */
export class Esm5ReflectionHost extends Fesm2015ReflectionHost { export class Esm5ReflectionHost extends Esm2015ReflectionHost {
constructor(isCore: boolean, checker: ts.TypeChecker) { super(isCore, checker); } constructor(isCore: boolean, checker: ts.TypeChecker) { super(isCore, checker); }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,6 @@ import {SwitchMarkerAnalyzer} from '../analysis/switch_marker_analyzer';
import {DtsMapper} from '../host/dts_mapper'; import {DtsMapper} from '../host/dts_mapper';
import {Esm2015ReflectionHost} from '../host/esm2015_host'; import {Esm2015ReflectionHost} from '../host/esm2015_host';
import {Esm5ReflectionHost} from '../host/esm5_host'; import {Esm5ReflectionHost} from '../host/esm5_host';
import {Fesm2015ReflectionHost} from '../host/fesm2015_host';
import {NgccReflectionHost} from '../host/ngcc_host'; import {NgccReflectionHost} from '../host/ngcc_host';
import {Esm2015Renderer} from '../rendering/esm2015_renderer'; import {Esm2015Renderer} from '../rendering/esm2015_renderer';
import {Esm5Renderer} from '../rendering/esm5_renderer'; import {Esm5Renderer} from '../rendering/esm5_renderer';
@ -111,9 +110,8 @@ export class Transformer {
NgccReflectionHost { NgccReflectionHost {
switch (format) { switch (format) {
case 'esm2015': case 'esm2015':
return new Esm2015ReflectionHost(isCore, program.getTypeChecker(), dtsMapper);
case 'fesm2015': case 'fesm2015':
return new Fesm2015ReflectionHost(isCore, program.getTypeChecker()); return new Esm2015ReflectionHost(isCore, program.getTypeChecker(), dtsMapper);
case 'esm5': case 'esm5':
case 'fesm5': case 'fesm5':
return new Esm5ReflectionHost(isCore, program.getTypeChecker()); return new Esm5ReflectionHost(isCore, program.getTypeChecker());

View File

@ -10,7 +10,7 @@ import * as ts from 'typescript';
import {Decorator} from '../../../ngtsc/host'; import {Decorator} from '../../../ngtsc/host';
import {DecoratorHandler} from '../../../ngtsc/transform'; import {DecoratorHandler} from '../../../ngtsc/transform';
import {DecorationAnalyses, DecorationAnalyzer} from '../../src/analysis/decoration_analyzer'; import {DecorationAnalyses, DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host'; import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
import {makeProgram} from '../helpers/utils'; import {makeProgram} from '../helpers/utils';
@ -57,7 +57,7 @@ describe('DecorationAnalyzer', () => {
beforeEach(() => { beforeEach(() => {
program = makeProgram(TEST_PROGRAM); program = makeProgram(TEST_PROGRAM);
const analyzer = new DecorationAnalyzer( const analyzer = new DecorationAnalyzer(
program.getTypeChecker(), new Fesm2015ReflectionHost(false, program.getTypeChecker()), program.getTypeChecker(), new Esm2015ReflectionHost(false, program.getTypeChecker()),
[''], false); [''], false);
testHandler = createTestHandler(); testHandler = createTestHandler();
analyzer.handlers = [testHandler]; analyzer.handlers = [testHandler];

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer'; import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host'; import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
import {makeProgram} from '../helpers/utils'; import {makeProgram} from '../helpers/utils';
const TEST_PROGRAM = [ const TEST_PROGRAM = [
@ -47,7 +47,7 @@ describe('SwitchMarkerAnalyzer', () => {
describe('analyzeProgram()', () => { describe('analyzeProgram()', () => {
it('should check for switchable markers in all the files of the program', () => { it('should check for switchable markers in all the files of the program', () => {
const program = makeProgram(...TEST_PROGRAM); const program = makeProgram(...TEST_PROGRAM);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const analyzer = new SwitchMarkerAnalyzer(host); const analyzer = new SwitchMarkerAnalyzer(host);
const analysis = analyzer.analyzeProgram(program); const analysis = analyzer.analyzeProgram(program);

View File

@ -9,7 +9,7 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {ClassMemberKind, Import} from '../../../ngtsc/host'; import {ClassMemberKind, Import} from '../../../ngtsc/host';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host'; import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
import {convertToDirectTsLibImport, getDeclaration, makeProgram} from '../helpers/utils'; import {convertToDirectTsLibImport, getDeclaration, makeProgram} from '../helpers/utils';
const FILES = [ const FILES = [
@ -104,7 +104,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
describe('getDecoratorsOfDeclaration()', () => { describe('getDecoratorsOfDeclaration()', () => {
it('should find the decorators on a class', () => { it('should find the decorators on a class', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const decorators = host.getDecoratorsOfDeclaration(classNode) !; const decorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -121,14 +121,14 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
}); });
it('should use `getImportOfIdentifier()` to retrieve import info', () => { it('should use `getImportOfIdentifier()` to retrieve import info', () => {
const spy = spyOn(Fesm2015ReflectionHost.prototype, 'getImportOfIdentifier') const spy = spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier')
.and.callFake( .and.callFake(
(identifier: ts.Identifier) => identifier.getText() === 'Directive' ? (identifier: ts.Identifier) => identifier.getText() === 'Directive' ?
{from: '@angular/core', name: 'Directive'} : {from: '@angular/core', name: 'Directive'} :
{}); {});
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
@ -143,7 +143,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should support decorators being used inside @angular/core', () => { it('should support decorators being used inside @angular/core', () => {
const program = makeProgram(fileSystem.files[1]); const program = makeProgram(fileSystem.files[1]);
const host = new Fesm2015ReflectionHost(true, program.getTypeChecker()); const host = new Esm2015ReflectionHost(true, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/node_modules/@angular/core/some_directive.js', 'SomeDirective', program, '/node_modules/@angular/core/some_directive.js', 'SomeDirective',
ts.isVariableDeclaration); ts.isVariableDeclaration);
@ -164,7 +164,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
describe('getMembersOfClass()', () => { describe('getMembersOfClass()', () => {
it('should find decorated members on a class', () => { it('should find decorated members on a class', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const members = host.getMembersOfClass(classNode); const members = host.getMembersOfClass(classNode);
@ -182,7 +182,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should find non decorated properties on a class', () => { it('should find non decorated properties on a class', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const members = host.getMembersOfClass(classNode); const members = host.getMembersOfClass(classNode);
@ -196,7 +196,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should find static methods on a class', () => { it('should find static methods on a class', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const members = host.getMembersOfClass(classNode); const members = host.getMembersOfClass(classNode);
@ -209,7 +209,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should find static properties on a class', () => { it('should find static properties on a class', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
@ -223,10 +223,10 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should use `getImportOfIdentifier()` to retrieve import info', () => { it('should use `getImportOfIdentifier()` to retrieve import info', () => {
const spy = const spy =
spyOn(Fesm2015ReflectionHost.prototype, 'getImportOfIdentifier').and.returnValue({}); spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier').and.returnValue({});
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
@ -237,7 +237,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should support decorators being used inside @angular/core', () => { it('should support decorators being used inside @angular/core', () => {
const program = makeProgram(fileSystem.files[1]); const program = makeProgram(fileSystem.files[1]);
const host = new Fesm2015ReflectionHost(true, program.getTypeChecker()); const host = new Esm2015ReflectionHost(true, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/node_modules/@angular/core/some_directive.js', 'SomeDirective', program, '/node_modules/@angular/core/some_directive.js', 'SomeDirective',
ts.isVariableDeclaration); ts.isVariableDeclaration);
@ -253,7 +253,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
describe('getConstructorParameters', () => { describe('getConstructorParameters', () => {
it('should find the decorated constructor parameters', () => { it('should find the decorated constructor parameters', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const parameters = host.getConstructorParameters(classNode); const parameters = host.getConstructorParameters(classNode);
@ -270,11 +270,11 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
describe('(returned parameters `decorators`)', () => { describe('(returned parameters `decorators`)', () => {
it('should use `getImportOfIdentifier()` to retrieve import info', () => { it('should use `getImportOfIdentifier()` to retrieve import info', () => {
const mockImportInfo = {} as Import; const mockImportInfo = {} as Import;
const spy = spyOn(Fesm2015ReflectionHost.prototype, 'getImportOfIdentifier') const spy = spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier')
.and.returnValue(mockImportInfo); .and.returnValue(mockImportInfo);
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const parameters = host.getConstructorParameters(classNode); const parameters = host.getConstructorParameters(classNode);
@ -292,7 +292,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
describe('getDeclarationOfIdentifier', () => { describe('getDeclarationOfIdentifier', () => {
it('should return the declaration of a locally defined identifier', () => { it('should return the declaration of a locally defined identifier', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const ctrDecorators = host.getConstructorParameters(classNode) !; const ctrDecorators = host.getConstructorParameters(classNode) !;
@ -308,7 +308,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should return the declaration of an externally defined identifier', () => { it('should return the declaration of an externally defined identifier', () => {
const program = makeProgram(fileSystem.files[0]); const program = makeProgram(fileSystem.files[0]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const classNode = getDeclaration( const classNode = getDeclaration(
program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration); program, '/some_directive.js', 'SomeDirective', ts.isVariableDeclaration);
const classDecorators = host.getDecoratorsOfDeclaration(classNode) !; const classDecorators = host.getDecoratorsOfDeclaration(classNode) !;
@ -331,7 +331,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
describe('getVariableValue', () => { describe('getVariableValue', () => {
it('should find the "actual" declaration of an aliased variable identifier', () => { it('should find the "actual" declaration of an aliased variable identifier', () => {
const program = makeProgram(fileSystem.files[2]); const program = makeProgram(fileSystem.files[2]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const ngModuleRef = findVariableDeclaration( const ngModuleRef = findVariableDeclaration(
program.getSourceFile(fileSystem.files[2].name) !, 'HttpClientXsrfModule_1'); program.getSourceFile(fileSystem.files[2].name) !, 'HttpClientXsrfModule_1');
@ -346,7 +346,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should return null if the variable has no assignment', () => { it('should return null if the variable has no assignment', () => {
const program = makeProgram(fileSystem.files[2]); const program = makeProgram(fileSystem.files[2]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const missingValue = findVariableDeclaration( const missingValue = findVariableDeclaration(
program.getSourceFile(fileSystem.files[2].name) !, 'missingValue'); program.getSourceFile(fileSystem.files[2].name) !, 'missingValue');
const value = host.getVariableValue(missingValue !); const value = host.getVariableValue(missingValue !);
@ -355,7 +355,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
it('should return null if the variable is not assigned from a call to __decorate', () => { it('should return null if the variable is not assigned from a call to __decorate', () => {
const program = makeProgram(fileSystem.files[2]); const program = makeProgram(fileSystem.files[2]);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const nonDecoratedVar = findVariableDeclaration( const nonDecoratedVar = findVariableDeclaration(
program.getSourceFile(fileSystem.files[2].name) !, 'nonDecoratedVar'); program.getSourceFile(fileSystem.files[2].name) !, 'nonDecoratedVar');
const value = host.getVariableValue(nonDecoratedVar !); const value = host.getVariableValue(nonDecoratedVar !);

File diff suppressed because it is too large Load Diff

View File

@ -9,8 +9,8 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {ClassMemberKind, Import} from '../../../ngtsc/host'; import {ClassMemberKind, Import} from '../../../ngtsc/host';
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
import {Esm5ReflectionHost} from '../../src/host/esm5_host'; import {Esm5ReflectionHost} from '../../src/host/esm5_host';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
import {getDeclaration, makeProgram} from '../helpers/utils'; import {getDeclaration, makeProgram} from '../helpers/utils';
const SOME_DIRECTIVE_FILE = { const SOME_DIRECTIVE_FILE = {
@ -1153,7 +1153,7 @@ describe('Esm5ReflectionHost', () => {
let superGetClassSymbolSpy: jasmine.Spy; let superGetClassSymbolSpy: jasmine.Spy;
beforeEach(() => { beforeEach(() => {
superGetClassSymbolSpy = spyOn(Fesm2015ReflectionHost.prototype, 'getClassSymbol'); superGetClassSymbolSpy = spyOn(Esm2015ReflectionHost.prototype, 'getClassSymbol');
}); });
it('should return the class symbol returned by the superclass (if any)', () => { it('should return the class symbol returned by the superclass (if any)', () => {
@ -1221,7 +1221,7 @@ describe('Esm5ReflectionHost', () => {
host = new Esm5ReflectionHost(false, null as any); host = new Esm5ReflectionHost(false, null as any);
mockNode = {} as any; mockNode = {} as any;
superIsClassSpy = spyOn(Fesm2015ReflectionHost.prototype, 'isClass'); superIsClassSpy = spyOn(Esm2015ReflectionHost.prototype, 'isClass');
getClassSymbolSpy = spyOn(Esm5ReflectionHost.prototype, 'getClassSymbol'); getClassSymbolSpy = spyOn(Esm5ReflectionHost.prototype, 'getClassSymbol');
}); });

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ import {makeProgram} from '../helpers/utils';
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer'; import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer'; import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
import {DtsMapper} from '../../src/host/dts_mapper'; import {DtsMapper} from '../../src/host/dts_mapper';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host'; import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
import {Esm2015Renderer} from '../../src/rendering/esm2015_renderer'; import {Esm2015Renderer} from '../../src/rendering/esm2015_renderer';
function setup(file: {name: string, contents: string}, transformDts: boolean = false) { function setup(file: {name: string, contents: string}, transformDts: boolean = false) {
@ -21,7 +21,7 @@ function setup(file: {name: string, contents: string}, transformDts: boolean = f
const dtsMapper = new DtsMapper(dir, dir); const dtsMapper = new DtsMapper(dir, dir);
const program = makeProgram(file); const program = makeProgram(file);
const sourceFile = program.getSourceFile(file.name) !; const sourceFile = program.getSourceFile(file.name) !;
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(program.getTypeChecker(), host, [''], false).analyzeProgram(program); new DecorationAnalyzer(program.getTypeChecker(), host, [''], false).analyzeProgram(program);
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(program); const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(program);

View File

@ -13,11 +13,11 @@ import {fromObject, generateMapFileComment} from 'convert-source-map';
import {makeProgram} from '../helpers/utils'; import {makeProgram} from '../helpers/utils';
import {AnalyzedClass, DecorationAnalyzer, DecorationAnalyses} from '../../src/analysis/decoration_analyzer'; import {AnalyzedClass, DecorationAnalyzer, DecorationAnalyses} from '../../src/analysis/decoration_analyzer';
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer'; import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host'; import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
import {Renderer} from '../../src/rendering/renderer'; import {Renderer} from '../../src/rendering/renderer';
class TestRenderer extends Renderer { class TestRenderer extends Renderer {
constructor(host: Fesm2015ReflectionHost) { super(host, false, null, '/src', '/dist'); } constructor(host: Esm2015ReflectionHost) { super(host, false, null, '/src', '/dist'); }
addImports(output: MagicString, imports: {name: string, as: string}[]) { addImports(output: MagicString, imports: {name: string, as: string}[]) {
output.prepend('\n// ADD IMPORTS\n'); output.prepend('\n// ADD IMPORTS\n');
} }
@ -37,7 +37,7 @@ class TestRenderer extends Renderer {
function createTestRenderer(file: {name: string, contents: string}) { function createTestRenderer(file: {name: string, contents: string}) {
const program = makeProgram(file); const program = makeProgram(file);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker()); const host = new Esm2015ReflectionHost(false, program.getTypeChecker());
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(program.getTypeChecker(), host, [''], false).analyzeProgram(program); new DecorationAnalyzer(program.getTypeChecker(), host, [''], false).analyzeProgram(program);
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(program); const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(program);