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;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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>>>();
|
|
|
|
|
2016-12-27 12:36:47 -05:00
|
|
|
isLibraryFile(fileName: string): boolean { return false; };
|
2017-03-24 12:59:58 -04:00
|
|
|
getLibraryFileName(fileName: string): string|null { return null; }
|
2017-04-26 12:24:42 -04:00
|
|
|
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); };
|
2016-11-29 18:36:33 -05:00
|
|
|
}
|