refactor(ivy): rename Esm2015ReflectionHost
to Fesm2015ReflectionHost
(#25406)
PR Close #25406
This commit is contained in:

committed by
Matias Niemelä

parent
c8baace554
commit
6ae1e63c89
@ -9,7 +9,7 @@ import * as ts from 'typescript';
|
||||
import {Decorator} from '../../ngtsc/host';
|
||||
import {DecoratorHandler} from '../../ngtsc/transform';
|
||||
import {AnalyzedFile, Analyzer} from '../src/analyzer';
|
||||
import {Esm2015ReflectionHost} from '../src/host/esm2015_host';
|
||||
import {Fesm2015ReflectionHost} from '../src/host/fesm2015_host';
|
||||
import {ParsedClass} from '../src/parsing/parsed_class';
|
||||
import {ParsedFile} from '../src/parsing/parsed_file';
|
||||
import {getDeclaration, makeProgram} from './helpers/utils';
|
||||
@ -80,7 +80,7 @@ describe('Analyzer', () => {
|
||||
program = makeProgram(TEST_PROGRAM);
|
||||
const file = createParsedFile(program);
|
||||
const analyzer = new Analyzer(
|
||||
program.getTypeChecker(), new Esm2015ReflectionHost(program.getTypeChecker()));
|
||||
program.getTypeChecker(), new Fesm2015ReflectionHost(program.getTypeChecker()));
|
||||
testHandler = createTestHandler();
|
||||
analyzer.handlers = [testHandler];
|
||||
result = analyzer.analyzeFile(file);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import * as ts from 'typescript';
|
||||
import {ClassMemberKind, Import} from '../../../ngtsc/host';
|
||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
|
||||
import {getDeclaration, makeProgram} from '../helpers/utils';
|
||||
|
||||
const SOME_DIRECTIVE_FILE = {
|
||||
@ -390,7 +390,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getDecoratorsOfDeclaration()', () => {
|
||||
it('should find the decorators on a class', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -408,7 +408,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return null if the symbol is not a class', () => {
|
||||
const program = makeProgram(FOO_FUNCTION_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const functionNode =
|
||||
getDeclaration(program, FOO_FUNCTION_FILE.name, 'foo', ts.isFunctionDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(functionNode);
|
||||
@ -417,7 +417,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return null if there are no decorators', () => {
|
||||
const program = makeProgram(SIMPLE_CLASS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SIMPLE_CLASS_FILE.name, 'EmptyClass', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode);
|
||||
@ -426,7 +426,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore `decorators` if it is not an array literal', () => {
|
||||
const program = makeProgram(INVALID_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATORS_FILE.name, 'NotArrayLiteral', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode);
|
||||
@ -435,7 +435,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore decorator elements that are not object literals', () => {
|
||||
const program = makeProgram(INVALID_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATORS_FILE.name, 'NotObjectLiteral', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -446,7 +446,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore decorator elements that have no `type` property', () => {
|
||||
const program = makeProgram(INVALID_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATORS_FILE.name, 'NoTypeProperty', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -457,7 +457,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore decorator elements whose `type` value is not an identifier', () => {
|
||||
const program = makeProgram(INVALID_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATORS_FILE.name, 'NotIdentifier', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -468,11 +468,11 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should use `getImportOfIdentifier()` to retrieve import info', () => {
|
||||
const mockImportInfo = {} as Import;
|
||||
const spy = spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier')
|
||||
const spy = spyOn(Fesm2015ReflectionHost.prototype, 'getImportOfIdentifier')
|
||||
.and.returnValue(mockImportInfo);
|
||||
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -487,7 +487,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('(returned decorators `args`)', () => {
|
||||
it('should be an empty array if decorator has no `args` property', () => {
|
||||
const program = makeProgram(INVALID_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATOR_ARGS_FILE.name, 'NoArgsProperty', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -499,7 +499,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should be an empty array if decorator\'s `args` has no property assignment', () => {
|
||||
const program = makeProgram(INVALID_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATOR_ARGS_FILE.name, 'NoPropertyAssignment',
|
||||
ts.isClassDeclaration);
|
||||
@ -512,7 +512,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should be an empty array if `args` property value is not an array literal', () => {
|
||||
const program = makeProgram(INVALID_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_DECORATOR_ARGS_FILE.name, 'NotArrayLiteral', ts.isClassDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -527,7 +527,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getMembersOfClass()', () => {
|
||||
it('should find decorated properties on a class', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -545,7 +545,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should find non decorated properties on a class', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -559,7 +559,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should find static methods on a class', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -572,7 +572,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should find static properties on a class', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -586,7 +586,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should throw if the symbol is not a class', () => {
|
||||
const program = makeProgram(FOO_FUNCTION_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const functionNode =
|
||||
getDeclaration(program, FOO_FUNCTION_FILE.name, 'foo', ts.isFunctionDeclaration);
|
||||
expect(() => {
|
||||
@ -596,7 +596,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return an empty array if there are no prop decorators', () => {
|
||||
const program = makeProgram(SIMPLE_CLASS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SIMPLE_CLASS_FILE.name, 'EmptyClass', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -607,7 +607,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
it('should not process decorated properties in `propDecorators` if it is not an object literal',
|
||||
() => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATORS_FILE.name, 'NotObjectLiteral', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -617,7 +617,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore prop decorator elements that are not object literals', () => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATORS_FILE.name, 'NotObjectLiteralProp',
|
||||
ts.isClassDeclaration);
|
||||
@ -633,7 +633,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore prop decorator elements that have no `type` property', () => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATORS_FILE.name, 'NoTypeProperty', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -646,7 +646,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore prop decorator elements whose `type` value is not an identifier', () => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATORS_FILE.name, 'NotIdentifier', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -660,13 +660,13 @@ describe('Esm2015ReflectionHost', () => {
|
||||
it('should use `getImportOfIdentifier()` to retrieve import info', () => {
|
||||
let callCount = 0;
|
||||
const spy =
|
||||
spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier').and.callFake(() => {
|
||||
spyOn(Fesm2015ReflectionHost.prototype, 'getImportOfIdentifier').and.callFake(() => {
|
||||
callCount++;
|
||||
return {name: `name${callCount}`, from: `from${callCount}`};
|
||||
});
|
||||
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
@ -688,7 +688,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('(returned prop decorators `args`)', () => {
|
||||
it('should be an empty array if prop decorator has no `args` property', () => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATOR_ARGS_FILE.name, 'NoArgsProperty',
|
||||
ts.isClassDeclaration);
|
||||
@ -703,7 +703,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should be an empty array if prop decorator\'s `args` has no property assignment', () => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATOR_ARGS_FILE.name, 'NoPropertyAssignment',
|
||||
ts.isClassDeclaration);
|
||||
@ -718,7 +718,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should be an empty array if `args` property value is not an array literal', () => {
|
||||
const program = makeProgram(INVALID_PROP_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_PROP_DECORATOR_ARGS_FILE.name, 'NotArrayLiteral',
|
||||
ts.isClassDeclaration);
|
||||
@ -736,7 +736,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getConstructorParameters()', () => {
|
||||
it('should find the decorated constructor parameters', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -752,7 +752,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should throw if the symbol is not a class', () => {
|
||||
const program = makeProgram(FOO_FUNCTION_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const functionNode =
|
||||
getDeclaration(program, FOO_FUNCTION_FILE.name, 'foo', ts.isFunctionDeclaration);
|
||||
expect(() => { host.getConstructorParameters(functionNode); })
|
||||
@ -762,7 +762,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return `null` if there is no constructor', () => {
|
||||
const program = makeProgram(SIMPLE_CLASS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SIMPLE_CLASS_FILE.name, 'EmptyClass', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -771,7 +771,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return an array even if there are no decorators', () => {
|
||||
const program = makeProgram(SIMPLE_CLASS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, SIMPLE_CLASS_FILE.name, 'NoDecoratorConstructorClass', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -784,7 +784,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return an empty array if there are no constructor parameters', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATORS_FILE.name, 'NoParameters', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -794,7 +794,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore `ctorParameters` if it is not an arrow function', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATORS_FILE.name, 'NotArrowFunction', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -808,7 +808,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore `ctorParameters` if it does not return an array literal', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATORS_FILE.name, 'NotArrayLiteral', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -823,7 +823,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('(returned parameters `decorators`)', () => {
|
||||
it('should ignore param decorator elements that are not object literals', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATORS_FILE.name, 'NotObjectLiteral', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -841,7 +841,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore param decorator elements that have no `type` property', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATORS_FILE.name, 'NoTypeProperty', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -853,7 +853,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should ignore param decorator elements whose `type` value is not an identifier', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATORS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATORS_FILE.name, 'NotIdentifier', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -865,11 +865,11 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should use `getImportOfIdentifier()` to retrieve import info', () => {
|
||||
const mockImportInfo = {} as Import;
|
||||
const spy = spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier')
|
||||
const spy = spyOn(Fesm2015ReflectionHost.prototype, 'getImportOfIdentifier')
|
||||
.and.returnValue(mockImportInfo);
|
||||
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
@ -886,7 +886,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('(returned parameters `decorators.args`)', () => {
|
||||
it('should be an empty array if param decorator has no `args` property', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATOR_ARGS_FILE.name, 'NoArgsProperty',
|
||||
ts.isClassDeclaration);
|
||||
@ -901,7 +901,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should be an empty array if param decorator\'s `args` has no property assignment', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATOR_ARGS_FILE.name, 'NoPropertyAssignment',
|
||||
ts.isClassDeclaration);
|
||||
@ -915,7 +915,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should be an empty array if `args` property value is not an array literal', () => {
|
||||
const program = makeProgram(INVALID_CTOR_DECORATOR_ARGS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode = getDeclaration(
|
||||
program, INVALID_CTOR_DECORATOR_ARGS_FILE.name, 'NotArrayLiteral',
|
||||
ts.isClassDeclaration);
|
||||
@ -932,7 +932,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getDefinitionOfFunction()', () => {
|
||||
it('should return an object describing the function declaration passed as an argument', () => {
|
||||
const program = makeProgram(FUNCTION_BODY_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
|
||||
const fooNode =
|
||||
getDeclaration(program, FUNCTION_BODY_FILE.name, 'foo', ts.isFunctionDeclaration) !;
|
||||
@ -994,7 +994,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getImportOfIdentifier()', () => {
|
||||
it('should find the import of an identifier', () => {
|
||||
const program = makeProgram(...IMPORTS_FILES);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const variableNode =
|
||||
getDeclaration(program, IMPORTS_FILES[1].name, 'b', ts.isVariableDeclaration);
|
||||
const importOfIdent = host.getImportOfIdentifier(variableNode.initializer as ts.Identifier);
|
||||
@ -1004,7 +1004,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should find the name by which the identifier was exported, not imported', () => {
|
||||
const program = makeProgram(...IMPORTS_FILES);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const variableNode =
|
||||
getDeclaration(program, IMPORTS_FILES[1].name, 'c', ts.isVariableDeclaration);
|
||||
const importOfIdent = host.getImportOfIdentifier(variableNode.initializer as ts.Identifier);
|
||||
@ -1014,7 +1014,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return null if the identifier was not imported', () => {
|
||||
const program = makeProgram(...IMPORTS_FILES);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const variableNode =
|
||||
getDeclaration(program, IMPORTS_FILES[1].name, 'd', ts.isVariableDeclaration);
|
||||
const importOfIdent = host.getImportOfIdentifier(variableNode.initializer as ts.Identifier);
|
||||
@ -1026,7 +1026,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getDeclarationOfIdentifier()', () => {
|
||||
it('should return the declaration of a locally defined identifier', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const ctrDecorators = host.getConstructorParameters(classNode) !;
|
||||
@ -1042,7 +1042,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return the declaration of an externally defined identifier', () => {
|
||||
const program = makeProgram(SOME_DIRECTIVE_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const classNode =
|
||||
getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration);
|
||||
const classDecorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
@ -1062,7 +1062,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('getExportsOfModule()', () => {
|
||||
it('should return a map of all the exports from a given module', () => {
|
||||
const program = makeProgram(...EXPORTS_FILES);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const file = program.getSourceFile(EXPORTS_FILES[1].name) !;
|
||||
const exportDeclarations = host.getExportsOfModule(file);
|
||||
expect(exportDeclarations).not.toBe(null);
|
||||
@ -1097,7 +1097,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
describe('isClass()', () => {
|
||||
it('should return true if a given node is a TS class declaration', () => {
|
||||
const program = makeProgram(SIMPLE_CLASS_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const node =
|
||||
getDeclaration(program, SIMPLE_CLASS_FILE.name, 'EmptyClass', ts.isClassDeclaration);
|
||||
expect(host.isClass(node)).toBe(true);
|
||||
@ -1105,7 +1105,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||
|
||||
it('should return false if a given node is a TS function declaration', () => {
|
||||
const program = makeProgram(FOO_FUNCTION_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const node = getDeclaration(program, FOO_FUNCTION_FILE.name, 'foo', ts.isFunctionDeclaration);
|
||||
expect(host.isClass(node)).toBe(false);
|
||||
});
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import * as ts from 'typescript';
|
||||
import {ClassMemberKind, Import} from '../../../ngtsc/host';
|
||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||
import {Esm5ReflectionHost} from '../../src/host/esm5_host';
|
||||
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
|
||||
import {getDeclaration, makeProgram} from '../helpers/utils';
|
||||
|
||||
const SOME_DIRECTIVE_FILE = {
|
||||
@ -1128,7 +1128,7 @@ describe('Esm5ReflectionHost', () => {
|
||||
let superGetClassSymbolSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
superGetClassSymbolSpy = spyOn(Esm2015ReflectionHost.prototype, 'getClassSymbol');
|
||||
superGetClassSymbolSpy = spyOn(Fesm2015ReflectionHost.prototype, 'getClassSymbol');
|
||||
});
|
||||
|
||||
it('should return the class symbol returned by the superclass (if any)', () => {
|
||||
@ -1194,7 +1194,7 @@ describe('Esm5ReflectionHost', () => {
|
||||
host = new Esm5ReflectionHost(null as any);
|
||||
mockNode = {} as any;
|
||||
|
||||
superIsClassSpy = spyOn(Esm2015ReflectionHost.prototype, 'isClass');
|
||||
superIsClassSpy = spyOn(Fesm2015ReflectionHost.prototype, 'isClass');
|
||||
getClassSymbolSpy = spyOn(Esm5ReflectionHost.prototype, 'getClassSymbol');
|
||||
});
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
|
||||
import {Esm2015FileParser} from '../../src/parsing/esm2015_parser';
|
||||
import {makeProgram} from '../helpers/utils';
|
||||
|
||||
@ -39,7 +39,7 @@ describe('Esm2015PackageParser', () => {
|
||||
describe('getDecoratedClasses()', () => {
|
||||
it('should return an array of object for each class that is exported and decorated', () => {
|
||||
const program = makeProgram(BASIC_FILE);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const parser = new Esm2015FileParser(program, host);
|
||||
|
||||
const parsedFiles = parser.parseFile(program.getSourceFile(BASIC_FILE.name) !);
|
||||
|
@ -9,13 +9,13 @@ import * as ts from 'typescript';
|
||||
import MagicString from 'magic-string';
|
||||
import {makeProgram} from '../helpers/utils';
|
||||
import {Analyzer} from '../../src/analyzer';
|
||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
|
||||
import {Esm2015FileParser} from '../../src/parsing/esm2015_parser';
|
||||
import {Esm2015Renderer} from '../../src/rendering/esm2015_renderer';
|
||||
|
||||
function setup(file: {name: string, contents: string}) {
|
||||
const program = makeProgram(file);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const parser = new Esm2015FileParser(program, host);
|
||||
const analyzer = new Analyzer(program.getTypeChecker(), host);
|
||||
const renderer = new Esm2015Renderer(host);
|
||||
|
@ -12,7 +12,7 @@ import MagicString from 'magic-string';
|
||||
import {fromObject, generateMapFileComment} from 'convert-source-map';
|
||||
import {makeProgram} from '../helpers/utils';
|
||||
import {AnalyzedClass, Analyzer} from '../../src/analyzer';
|
||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
|
||||
import {Esm2015FileParser} from '../../src/parsing/esm2015_parser';
|
||||
import {Renderer} from '../../src/rendering/renderer';
|
||||
|
||||
@ -32,7 +32,7 @@ class TestRenderer extends Renderer {
|
||||
}
|
||||
|
||||
function createTestRenderer() {
|
||||
const renderer = new TestRenderer({} as Esm2015ReflectionHost);
|
||||
const renderer = new TestRenderer({} as Fesm2015ReflectionHost);
|
||||
spyOn(renderer, 'addImports').and.callThrough();
|
||||
spyOn(renderer, 'addDefinitions').and.callThrough();
|
||||
spyOn(renderer, 'removeDecorators').and.callThrough();
|
||||
@ -41,7 +41,7 @@ function createTestRenderer() {
|
||||
|
||||
function analyze(file: {name: string, contents: string}) {
|
||||
const program = makeProgram(file);
|
||||
const host = new Esm2015ReflectionHost(program.getTypeChecker());
|
||||
const host = new Fesm2015ReflectionHost(program.getTypeChecker());
|
||||
const parser = new Esm2015FileParser(program, host);
|
||||
const analyzer = new Analyzer(program.getTypeChecker(), host);
|
||||
|
||||
|
Reference in New Issue
Block a user