refactor(ivy): move and rename Analyzer to DecorationAnalyzer (#26082)

This is in preparation for adding in other kinds of Analyzer.

PR Close #26082
This commit is contained in:
Pete Bacon Darwin
2018-09-26 20:53:45 +01:00
committed by Miško Hevery
parent 64c96186da
commit 880c0add56
8 changed files with 40 additions and 37 deletions

View File

@ -7,14 +7,14 @@
*/
import * as ts from 'typescript';
import {Decorator} from '../../ngtsc/host';
import {DecoratorHandler} from '../../ngtsc/transform';
import {AnalyzedFile, Analyzer} from '../src/analyzer';
import {DecoratedClass} from '../src/host/decorated_class';
import {DecoratedFile} from '../src/host/decorated_file';
import {Fesm2015ReflectionHost} from '../src/host/fesm2015_host';
import {Decorator} from '../../../ngtsc/host';
import {DecoratorHandler} from '../../../ngtsc/transform';
import {DecorationAnalysis, DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
import {DecoratedClass} from '../../src/host/decorated_class';
import {DecoratedFile} from '../../src/host/decorated_file';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
import {getDeclaration, makeProgram} from './helpers/utils';
import {getDeclaration, makeProgram} from '../helpers/utils';
const TEST_PROGRAM = {
name: 'test.js',
@ -74,16 +74,16 @@ function createParsedFile(program: ts.Program) {
return file;
}
describe('Analyzer', () => {
describe('DecorationAnalyzer', () => {
describe('analyzeFile()', () => {
let program: ts.Program;
let testHandler: jasmine.SpyObj<DecoratorHandler<any, any>>;
let result: AnalyzedFile;
let result: DecorationAnalysis;
beforeEach(() => {
program = makeProgram(TEST_PROGRAM);
const file = createParsedFile(program);
const analyzer = new Analyzer(
const analyzer = new DecorationAnalyzer(
program.getTypeChecker(), new Fesm2015ReflectionHost(false, program.getTypeChecker()),
[''], false);
testHandler = createTestHandler();

View File

@ -8,19 +8,19 @@
import * as ts from 'typescript';
import MagicString from 'magic-string';
import {makeProgram} from '../helpers/utils';
import {Analyzer} from '../../src/analyzer';
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
import {Esm2015Renderer} from '../../src/rendering/esm2015_renderer';
function setup(file: {name: string, contents: string}) {
const program = makeProgram(file);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker());
const analyzer = new Analyzer(program.getTypeChecker(), host, [''], false);
const analyzer = new DecorationAnalyzer(program.getTypeChecker(), host, [''], false);
const renderer = new Esm2015Renderer(host, false, null);
return {analyzer, host, program, renderer};
}
function analyze(host: Fesm2015ReflectionHost, analyzer: Analyzer, file: ts.SourceFile) {
function analyze(host: Fesm2015ReflectionHost, analyzer: DecorationAnalyzer, file: ts.SourceFile) {
const decoratedFiles = host.findDecoratedFiles(file);
return Array.from(decoratedFiles.values()).map(file => analyzer.analyzeFile(file))[0];
}

View File

@ -8,19 +8,19 @@
import * as ts from 'typescript';
import MagicString from 'magic-string';
import {makeProgram} from '../helpers/utils';
import {Analyzer} from '../../src/analyzer';
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
import {Esm5ReflectionHost} from '../../src/host/esm5_host';
import {Esm5Renderer} from '../../src/rendering/esm5_renderer';
function setup(file: {name: string, contents: string}) {
const program = makeProgram(file);
const host = new Esm5ReflectionHost(false, program.getTypeChecker());
const analyzer = new Analyzer(program.getTypeChecker(), host, [''], false);
const analyzer = new DecorationAnalyzer(program.getTypeChecker(), host, [''], false);
const renderer = new Esm5Renderer(host, false, null);
return {analyzer, host, program, renderer};
}
function analyze(host: Esm5ReflectionHost, analyzer: Analyzer, file: ts.SourceFile) {
function analyze(host: Esm5ReflectionHost, analyzer: DecorationAnalyzer, file: ts.SourceFile) {
const decoratedFiles = host.findDecoratedFiles(file);
return Array.from(decoratedFiles.values()).map(file => analyzer.analyzeFile(file))[0];
}

View File

@ -11,7 +11,7 @@ import * as ts from 'typescript';
import MagicString from 'magic-string';
import {fromObject, generateMapFileComment} from 'convert-source-map';
import {makeProgram} from '../helpers/utils';
import {AnalyzedClass, Analyzer} from '../../src/analyzer';
import {AnalyzedClass, DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
import {Fesm2015ReflectionHost} from '../../src/host/fesm2015_host';
import {Renderer} from '../../src/rendering/renderer';
@ -44,7 +44,7 @@ function createTestRenderer() {
function analyze(file: {name: string, contents: string}) {
const program = makeProgram(file);
const host = new Fesm2015ReflectionHost(false, program.getTypeChecker());
const analyzer = new Analyzer(program.getTypeChecker(), host, [''], false);
const analyzer = new DecorationAnalyzer(program.getTypeChecker(), host, [''], false);
const decoratedFiles = host.findDecoratedFiles(program.getSourceFile(file.name) !);
const analyzedFiles = Array.from(decoratedFiles.values()).map(file => analyzer.analyzeFile(file));