2016-11-29 18:36:33 -05:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2016-12-02 13:08:46 -05:00
|
|
|
import {CompileTypeSummary} from './compile_metadata';
|
2017-08-16 12:00:03 -04:00
|
|
|
import {Type} from './core';
|
2016-11-29 18:36:33 -05:00
|
|
|
|
2016-12-15 12:12:40 -05:00
|
|
|
export interface Summary<T> {
|
|
|
|
symbol: T;
|
|
|
|
metadata: any;
|
|
|
|
type?: CompileTypeSummary;
|
|
|
|
}
|
|
|
|
|
2017-04-26 12:24:42 -04:00
|
|
|
export abstract class SummaryResolver<T> {
|
|
|
|
abstract isLibraryFile(fileName: string): boolean;
|
2017-08-15 17:41:48 -04:00
|
|
|
abstract toSummaryFileName(fileName: string, referringSrcFileName: string): string;
|
|
|
|
abstract fromSummaryFileName(fileName: string, referringLibFileName: string): string;
|
2017-04-26 12:24:42 -04:00
|
|
|
abstract resolveSummary(reference: T): Summary<T>|null;
|
|
|
|
abstract getSymbolsOf(filePath: string): T[];
|
|
|
|
abstract getImportAs(reference: T): T;
|
|
|
|
abstract addSummary(summary: Summary<T>): void;
|
|
|
|
}
|
|
|
|
|
2017-08-16 12:00:03 -04:00
|
|
|
export class JitSummaryResolver implements SummaryResolver<Type> {
|
|
|
|
private _summaries = new Map<Type, Summary<Type>>();
|
2017-04-26 12:24:42 -04:00
|
|
|
|
2017-08-15 17:41:48 -04:00
|
|
|
isLibraryFile(): boolean { return false; };
|
|
|
|
toSummaryFileName(fileName: string): string { return fileName; }
|
|
|
|
fromSummaryFileName(fileName: string): string { return fileName; }
|
2017-08-16 12:00:03 -04:00
|
|
|
resolveSummary(reference: Type): Summary<Type>|null {
|
2017-04-26 12:24:42 -04:00
|
|
|
return this._summaries.get(reference) || null;
|
|
|
|
};
|
2017-08-16 12:00:03 -04:00
|
|
|
getSymbolsOf(): Type[] { return []; }
|
|
|
|
getImportAs(reference: Type): Type { return reference; }
|
|
|
|
addSummary(summary: Summary<Type>) { this._summaries.set(summary.symbol, summary); };
|
2016-11-29 18:36:33 -05:00
|
|
|
}
|