refactor(compiler): Reintroduce ReflectorHost and move Extractor into @angular/compiler

This commit is contained in:
Tobias Bosch
2016-11-18 08:40:41 -08:00
committed by Chuck Jazdzewski
parent 3c06a5dc25
commit 2a5bd2f345
9 changed files with 173 additions and 130 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AotCompilerHost, StaticReflector, StaticSymbol} from '@angular/compiler';
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler';
import {HostListener, Inject, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
import {MetadataCollector} from '@angular/tsc-wrapped';
import * as ts from 'typescript';
@ -18,11 +18,11 @@ const TS_EXT = /(^.|(?!\.d)..)\.ts$/;
describe('StaticReflector', () => {
const noContext = new StaticSymbol('', '');
let host: AotCompilerHost;
let host: StaticReflectorHost;
let reflector: StaticReflector;
beforeEach(() => {
host = new MockAotCompilerHost();
host = new MockStaticReflectorHost();
reflector = new StaticReflector(host);
});
@ -519,17 +519,9 @@ describe('StaticReflector', () => {
});
class MockAotCompilerHost implements AotCompilerHost {
class MockStaticReflectorHost implements StaticReflectorHost {
private collector = new MetadataCollector();
constructor() {}
loadResource(filePath: string): Promise<string> { throw new Error('Should not be called!'); }
fileNameToModuleName(importedFilePath: string, containingFilePath: string): string {
throw new Error('Should not be called!');
}
// In tests, assume that symbols are not re-exported
moduleNameToFileName(modulePath: string, containingFile?: string): string {
function splitPath(path: string): string[] { return path.split(/\/|\\/g); }