refactor(ivy): make `ReflectionHost` a parameter of `Renderer` (#25406)

PR Close #25406
This commit is contained in:
George Kalpakas 2018-07-27 22:36:54 +03:00 committed by Matias Niemelä
parent ea68ba048a
commit 29705dd8f2
4 changed files with 15 additions and 21 deletions

View File

@ -7,13 +7,10 @@
*/
import * as ts from 'typescript';
import MagicString from 'magic-string';
import {NgccReflectionHost} from '../host/ngcc_host';
import {AnalyzedClass} from '../analyzer';
import {Renderer} from './renderer';
export class Esm2015Renderer extends Renderer {
constructor(protected host: NgccReflectionHost) { super(); }
/**
* Add the imports at the top of the file
*/

View File

@ -5,12 +5,6 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript';
import MagicString from 'magic-string';
import {NgccReflectionHost} from '../host/ngcc_host';
import {AnalyzedClass, AnalyzedFile} from '../analyzer';
import {Esm2015Renderer} from './esm2015_renderer';
export class Esm5Renderer extends Esm2015Renderer {
constructor(host: NgccReflectionHost) { super(host); }
}
export class Esm5Renderer extends Esm2015Renderer {}

View File

@ -5,16 +5,17 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {ConstantPool, Expression, Statement, WrappedNodeExpr, WritePropExpr} from '@angular/compiler';
import {SourceMapConverter, commentRegex, fromJSON, fromMapFileSource, fromObject, fromSource, generateMapFileComment, mapFileCommentRegex, removeComments, removeMapFileComments} from 'convert-source-map';
import MagicString from 'magic-string';
import {dirname} from 'path';
import {SourceMapConsumer, SourceMapGenerator, RawSourceMap} from 'source-map';
import * as ts from 'typescript';
import MagicString from 'magic-string';
import {commentRegex, mapFileCommentRegex, fromJSON, fromSource, fromMapFileSource, fromObject, generateMapFileComment, removeComments, removeMapFileComments, SourceMapConverter} from 'convert-source-map';
import {SourceMapConsumer, SourceMapGenerator, RawSourceMap} from 'source-map';
import {ConstantPool, Expression, Statement, WrappedNodeExpr, WritePropExpr} from '@angular/compiler';
import {AnalyzedClass, AnalyzedFile} from '../analyzer';
import {Decorator} from '../../../ngtsc/host';
import {ImportManager, translateStatement} from '../../../ngtsc/transform';
import {AnalyzedClass, AnalyzedFile} from '../analyzer';
import {NgccReflectionHost} from '../host/ngcc_host';
interface SourceMapInfo {
source: string;
@ -55,12 +56,14 @@ export interface FileInfo {
}
/**
* A base-class for rendering an `AnalyzedClass`.
* Package formats have output files that must be rendered differently,
* Concrete sub-classes must implement the `addImports`, `addDefinitions` and
* `removeDecorators` abstract methods.
* A base-class for rendering an `AnalyzedFile`.
*
* Package formats have output files that must be rendered differently. Concrete sub-classes must
* implement the `addImports`, `addDefinitions` and `removeDecorators` abstract methods.
*/
export abstract class Renderer {
constructor(protected host: NgccReflectionHost) {}
/**
* Render the source code and source-map for an Analyzed file.
* @param file The analyzed file to render.

View File

@ -32,7 +32,7 @@ class TestRenderer extends Renderer {
}
function createTestRenderer() {
const renderer = new TestRenderer();
const renderer = new TestRenderer({} as Esm2015ReflectionHost);
spyOn(renderer, 'addImports').and.callThrough();
spyOn(renderer, 'addDefinitions').and.callThrough();
spyOn(renderer, 'removeDecorators').and.callThrough();
@ -183,4 +183,4 @@ describe('Renderer', () => {
expect(result.map !.contents).toEqual(MERGED_OUTPUT_PROGRAM_MAP.toJSON());
});
});
});
});