feat: add .ngsummary.ts files to support AOT unit tests
Design doc: https://docs.google.com/document/d/1VmTkz0EbEVSWfEEWEvQ5sXyQXSCvtMOw4t7pKU-jOwc/edit?usp=sharing
This commit is contained in:

committed by
Matias Niemelä

parent
2714644528
commit
547c363473
@ -5,6 +5,7 @@
|
||||
* 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 {Type} from '@angular/core';
|
||||
import {CompileTypeSummary} from './compile_metadata';
|
||||
import {CompilerInjectable} from './injectable';
|
||||
|
||||
@ -14,11 +15,25 @@ export interface Summary<T> {
|
||||
type?: CompileTypeSummary;
|
||||
}
|
||||
|
||||
export abstract class SummaryResolver<T> {
|
||||
abstract isLibraryFile(fileName: string): boolean;
|
||||
abstract getLibraryFileName(fileName: string): string|null;
|
||||
abstract resolveSummary(reference: T): Summary<T>|null;
|
||||
abstract getSymbolsOf(filePath: string): T[];
|
||||
abstract getImportAs(reference: T): T;
|
||||
abstract addSummary(summary: Summary<T>): void;
|
||||
}
|
||||
|
||||
@CompilerInjectable()
|
||||
export class SummaryResolver<T> {
|
||||
export class JitSummaryResolver implements SummaryResolver<Type<any>> {
|
||||
private _summaries = new Map<Type<any>, Summary<Type<any>>>();
|
||||
|
||||
isLibraryFile(fileName: string): boolean { return false; };
|
||||
getLibraryFileName(fileName: string): string|null { return null; }
|
||||
resolveSummary(reference: T): Summary<T>|null { return null; };
|
||||
getSymbolsOf(filePath: string): T[] { return []; }
|
||||
getImportAs(reference: T): T { return reference; }
|
||||
resolveSummary(reference: Type<any>): Summary<Type<any>>|null {
|
||||
return this._summaries.get(reference) || null;
|
||||
};
|
||||
getSymbolsOf(filePath: string): Type<any>[] { return []; }
|
||||
getImportAs(reference: Type<any>): Type<any> { return reference; }
|
||||
addSummary(summary: Summary<Type<any>>) { this._summaries.set(summary.symbol, summary); };
|
||||
}
|
||||
|
Reference in New Issue
Block a user