diff --git a/packages/compiler-cli/src/ngcc/src/analyzer.ts b/packages/compiler-cli/src/ngcc/src/analysis/decoration_analyzer.ts
similarity index 86%
rename from packages/compiler-cli/src/ngcc/src/analyzer.ts
rename to packages/compiler-cli/src/ngcc/src/analysis/decoration_analyzer.ts
index 6cc6aae722..938bb5974f 100644
--- a/packages/compiler-cli/src/ngcc/src/analyzer.ts
+++ b/packages/compiler-cli/src/ngcc/src/analysis/decoration_analyzer.ts
@@ -9,13 +9,13 @@ import {ConstantPool} from '@angular/compiler';
import * as fs from 'fs';
import * as ts from 'typescript';
-import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ResourceLoader, SelectorScopeRegistry} from '../../ngtsc/annotations';
-import {CompileResult, DecoratorHandler} from '../../ngtsc/transform';
+import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ResourceLoader, SelectorScopeRegistry} from '../../../ngtsc/annotations';
+import {CompileResult, DecoratorHandler} from '../../../ngtsc/transform';
-import {DecoratedClass} from './host/decorated_class';
-import {DecoratedFile} from './host/decorated_file';
-import {NgccReflectionHost} from './host/ngcc_host';
-import {isDefined} from './utils';
+import {DecoratedClass} from '../host/decorated_class';
+import {DecoratedFile} from '../host/decorated_file';
+import {NgccReflectionHost} from '../host/ngcc_host';
+import {isDefined} from '../utils';
export interface AnalyzedClass extends DecoratedClass {
handler: DecoratorHandler;
@@ -24,7 +24,7 @@ export interface AnalyzedClass extends DecoratedClass {
compilation: CompileResult[];
}
-export interface AnalyzedFile {
+export interface DecorationAnalysis {
analyzedClasses: AnalyzedClass[];
sourceFile: ts.SourceFile;
constantPool: ConstantPool;
@@ -42,7 +42,10 @@ export class FileResourceLoader implements ResourceLoader {
load(url: string): string { return fs.readFileSync(url, 'utf8'); }
}
-export class Analyzer {
+/**
+ * This Analyzer will analyze the files that have decorated classes that need to be transformed.
+ */
+export class DecorationAnalyzer {
resourceLoader = new FileResourceLoader();
scopeRegistry = new SelectorScopeRegistry(this.typeChecker, this.host);
handlers: DecoratorHandler[] = [
@@ -65,7 +68,7 @@ export class Analyzer {
* should be converted to use ivy definitions.
* @param file The file to be analysed for decorated classes.
*/
- analyzeFile(file: DecoratedFile): AnalyzedFile {
+ analyzeFile(file: DecoratedFile): DecorationAnalysis {
const constantPool = new ConstantPool();
const analyzedClasses =
file.decoratedClasses.map(clazz => this.analyzeClass(constantPool, clazz))
diff --git a/packages/compiler-cli/src/ngcc/src/packages/transformer.ts b/packages/compiler-cli/src/ngcc/src/packages/transformer.ts
index 455c03d122..074004aa1c 100644
--- a/packages/compiler-cli/src/ngcc/src/packages/transformer.ts
+++ b/packages/compiler-cli/src/ngcc/src/packages/transformer.ts
@@ -11,7 +11,7 @@ import {mkdir, mv} from 'shelljs';
import * as ts from 'typescript';
import {DtsFileTransformer} from '../../../ngtsc/transform';
-import {AnalyzedFile, Analyzer} from '../analyzer';
+import {DecorationAnalysis, DecorationAnalyzer} from '../analysis/decoration_analyzer';
import {IMPORT_PREFIX} from '../constants';
import {DtsMapper} from '../host/dts_mapper';
import {Esm2015ReflectionHost} from '../host/esm2015_host';
@@ -77,7 +77,7 @@ export class Transformer {
const reflectionHost = this.getHost(isCore, format, packageProgram, dtsMapper);
const r3SymbolsFile = r3SymbolsPath && packageProgram.getSourceFile(r3SymbolsPath) || null;
- const analyzer = new Analyzer(typeChecker, reflectionHost, rootDirs, isCore);
+ const analyzer = new DecorationAnalyzer(typeChecker, reflectionHost, rootDirs, isCore);
const renderer =
this.getRenderer(format, packageProgram, reflectionHost, isCore, r3SymbolsFile);
@@ -147,7 +147,7 @@ export class Transformer {
}
transformDtsFiles(
- analyzedFiles: AnalyzedFile[], sourceNodeModules: string, targetNodeModules: string,
+ analyzedFiles: DecorationAnalysis[], sourceNodeModules: string, targetNodeModules: string,
dtsMapper: DtsMapper): FileInfo[] {
const outputFiles: FileInfo[] = [];
@@ -177,7 +177,7 @@ export class Transformer {
}
transformSourceFiles(
- analyzedFiles: AnalyzedFile[], sourceNodeModules: string, targetNodeModules: string,
+ analyzedFiles: DecorationAnalysis[], sourceNodeModules: string, targetNodeModules: string,
renderer: Renderer): FileInfo[] {
const outputFiles: FileInfo[] = [];
diff --git a/packages/compiler-cli/src/ngcc/src/rendering/esm2015_renderer.ts b/packages/compiler-cli/src/ngcc/src/rendering/esm2015_renderer.ts
index 831a239c9d..af9378e2c8 100644
--- a/packages/compiler-cli/src/ngcc/src/rendering/esm2015_renderer.ts
+++ b/packages/compiler-cli/src/ngcc/src/rendering/esm2015_renderer.ts
@@ -8,7 +8,7 @@
import * as ts from 'typescript';
import MagicString from 'magic-string';
import {POST_NGCC_MARKER, PRE_NGCC_MARKER} from '../host/ngcc_host';
-import {AnalyzedClass} from '../analyzer';
+import {AnalyzedClass} from '../analysis/decoration_analyzer';
import {Renderer} from './renderer';
export class Esm2015Renderer extends Renderer {
diff --git a/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts b/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts
index 7f04537c7c..1f3a55e1c2 100644
--- a/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts
+++ b/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts
@@ -15,10 +15,10 @@ import * as ts from 'typescript';
import {Decorator} from '../../../ngtsc/host';
import {translateStatement} from '../../../ngtsc/translator';
-import {NgccImportManager} from './ngcc_import_manager';
-import {AnalyzedClass, AnalyzedFile} from '../analyzer';
+import {AnalyzedClass, DecorationAnalysis} from '../analysis/decoration_analyzer';
import {IMPORT_PREFIX} from '../constants';
import {NgccReflectionHost} from '../host/ngcc_host';
+import {NgccImportManager} from './ngcc_import_manager';
interface SourceMapInfo {
source: string;
@@ -33,7 +33,7 @@ export interface RenderResult {
/**
* The file that has been rendered.
*/
- file: AnalyzedFile;
+ file: DecorationAnalysis;
/**
* The rendered source file.
*/
@@ -74,7 +74,7 @@ export abstract class Renderer {
* @param file The analyzed file to render.
* @param targetPath The absolute path where the rendered file will be written.
*/
- renderFile(file: AnalyzedFile, targetPath: string): RenderResult {
+ renderFile(file: DecorationAnalysis, targetPath: string): RenderResult {
const importManager =
new NgccImportManager(!this.rewriteCoreImportsTo, this.isCore, IMPORT_PREFIX);
const input = this.extractSourceMap(file.sourceFile);
@@ -180,7 +180,7 @@ export abstract class Renderer {
* with an appropriate source-map comment pointing to the merged source-map.
*/
protected renderSourceAndMap(
- file: AnalyzedFile, input: SourceMapInfo, output: MagicString,
+ file: DecorationAnalysis, input: SourceMapInfo, output: MagicString,
outputPath: string): RenderResult {
const outputMapPath = `${outputPath}.map`;
const outputMap = output.generateMap({
diff --git a/packages/compiler-cli/src/ngcc/test/analyzer_spec.ts b/packages/compiler-cli/src/ngcc/test/analysis/decoration_analyzer_spec.ts
similarity index 87%
rename from packages/compiler-cli/src/ngcc/test/analyzer_spec.ts
rename to packages/compiler-cli/src/ngcc/test/analysis/decoration_analyzer_spec.ts
index 486cba8ee9..8d4041a6f5 100644
--- a/packages/compiler-cli/src/ngcc/test/analyzer_spec.ts
+++ b/packages/compiler-cli/src/ngcc/test/analysis/decoration_analyzer_spec.ts
@@ -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>;
- 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();
diff --git a/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts b/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts
index cf976a0e2e..0894f43cf8 100644
--- a/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts
+++ b/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts
@@ -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];
}
diff --git a/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts b/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts
index 65b9014117..fdf7397516 100644
--- a/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts
+++ b/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts
@@ -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];
}
diff --git a/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts b/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts
index cccfd22fd4..8304c3fb28 100644
--- a/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts
+++ b/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts
@@ -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));