refactor(compiler): simplify the CompilerHost used for transformers

- remove unneeded methods (`getNgCanonicalFileName`, `assumeFileExists`)
- simplify moduleName <-> fileName conversion logic as we don’t need to
  account for `genDir` anymore.
- rename `createNgCompilerHost` -> `createCompilerHost`
This commit is contained in:
Tobias Bosch
2017-08-14 11:04:55 -07:00
committed by Hans
parent 27d5058e01
commit 6a1ab61cce
9 changed files with 310 additions and 333 deletions

View File

@ -82,12 +82,11 @@ export class StaticReflector implements CompileReflector {
}
resolveExternalReference(ref: o.ExternalReference): StaticSymbol {
const importSymbol = this.getStaticSymbol(ref.moduleName !, ref.name !);
const rootSymbol = this.findDeclaration(ref.moduleName !, ref.name !);
if (importSymbol != rootSymbol) {
this.symbolResolver.recordImportAs(rootSymbol, importSymbol);
}
return rootSymbol;
const refSymbol = this.symbolResolver.getSymbolByModule(ref.moduleName !, ref.name !);
const declarationSymbol = this.findSymbolDeclaration(refSymbol);
this.symbolResolver.recordModuleNameForFileName(refSymbol.filePath, ref.moduleName !);
this.symbolResolver.recordImportAs(declarationSymbol, refSymbol);
return declarationSymbol;
}
findDeclaration(moduleUrl: string, name: string, containingFile?: string): StaticSymbol {

View File

@ -172,6 +172,10 @@ export class StaticSymbolResolver {
this.importAs.set(sourceSymbol, targetSymbol);
}
recordModuleNameForFileName(fileName: string, moduleName: string) {
this.knownFileNameToModuleNames.set(fileName, moduleName);
}
/**
* Invalidate all information derived from the given file.
*