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
|
|
|
|
*/
|
2017-04-26 12:24:42 -04:00
|
|
|
import {Type} from '@angular/core';
|
2016-12-02 13:08:46 -05:00
|
|
|
import {CompileTypeSummary} from './compile_metadata';
|
2016-12-15 12:12:40 -05:00
|
|
|
import {CompilerInjectable} from './injectable';
|
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;
|
|
|
|
}
|
|
|
|
|
2016-12-15 12:12:40 -05:00
|
|
|
@CompilerInjectable()
|
2017-04-26 12:24:42 -04:00
|
|
|
export class JitSummaryResolver implements SummaryResolver<Type<any>> {
|
|
|
|
private _summaries = new Map<Type<any>, Summary<Type<any>>>();
|
|
|
|
|
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-04-26 12:24:42 -04:00
|
|
|
resolveSummary(reference: Type<any>): Summary<Type<any>>|null {
|
|
|
|
return this._summaries.get(reference) || null;
|
|
|
|
};
|
2017-08-15 17:41:48 -04:00
|
|
|
getSymbolsOf(): Type<any>[] { return []; }
|
2017-04-26 12:24:42 -04:00
|
|
|
getImportAs(reference: Type<any>): Type<any> { return reference; }
|
|
|
|
addSummary(summary: Summary<Type<any>>) { this._summaries.set(summary.symbol, summary); };
|
2016-11-29 18:36:33 -05:00
|
|
|
}
|