refactor(core): remove readonly getters in common, compiler (#19150)

PR Close #19150
This commit is contained in:
Yuan Gao
2017-09-11 15:10:19 -07:00
committed by Matias Niemelä
parent 996c7c2dde
commit 0c44e733ad
6 changed files with 56 additions and 52 deletions

View File

@ -245,15 +245,15 @@ class TypeWrapper implements Symbol {
return (symbol && symbol.name) || '<anonymous>';
}
get kind(): DeclarationKind { return 'type'; }
public readonly kind: DeclarationKind = 'type';
get language(): string { return 'typescript'; }
public readonly language: string = 'typescript';
get type(): Symbol|undefined { return undefined; }
public readonly type: Symbol|undefined = undefined;
get container(): Symbol|undefined { return undefined; }
public readonly container: Symbol|undefined = undefined;
get public(): boolean { return true; }
public readonly public: boolean = true;
get callable(): boolean { return typeCallable(this.tsType); }
@ -284,6 +284,9 @@ class SymbolWrapper implements Symbol {
private _tsType: ts.Type;
private _members: SymbolTable;
public readonly nullable: boolean = false;
public readonly language: string = 'typescript';
constructor(symbol: ts.Symbol, private context: TypeContext) {
this.symbol = symbol && context && (symbol.flags & ts.SymbolFlags.Alias) ?
context.checker.getAliasedSymbol(symbol) :
@ -294,8 +297,6 @@ class SymbolWrapper implements Symbol {
get kind(): DeclarationKind { return this.callable ? 'method' : 'property'; }
get language(): string { return 'typescript'; }
get type(): Symbol|undefined { return new TypeWrapper(this.tsType, this.context); }
get container(): Symbol|undefined { return getContainerOf(this.symbol, this.context); }
@ -307,8 +308,6 @@ class SymbolWrapper implements Symbol {
get callable(): boolean { return typeCallable(this.tsType); }
get nullable(): boolean { return false; }
get definition(): Definition { return definitionFromTsSymbol(this.symbol); }
members(): SymbolTable {
@ -343,23 +342,24 @@ class SymbolWrapper implements Symbol {
}
class DeclaredSymbol implements Symbol {
public readonly language: string = 'ng-template';
public readonly nullable: boolean = false;
public readonly public: boolean = true;
constructor(private declaration: SymbolDeclaration) {}
get name() { return this.declaration.name; }
get kind() { return this.declaration.kind; }
get language(): string { return 'ng-template'; }
get container(): Symbol|undefined { return undefined; }
get type() { return this.declaration.type; }
get callable(): boolean { return this.declaration.type.callable; }
get nullable(): boolean { return false; }
get public(): boolean { return true; }
get definition(): Definition { return this.declaration.definition; }
@ -512,25 +512,19 @@ class PipesTable implements SymbolTable {
class PipeSymbol implements Symbol {
private _tsType: ts.Type;
public readonly kind: DeclarationKind = 'pipe';
public readonly language: string = 'typescript';
public readonly container: Symbol|undefined = undefined;
public readonly callable: boolean = true;
public readonly nullable: boolean = false;
public readonly public: boolean = true;
constructor(private pipe: CompilePipeSummary, private context: TypeContext) {}
get name(): string { return this.pipe.name; }
get kind(): DeclarationKind { return 'pipe'; }
get language(): string { return 'typescript'; }
get type(): Symbol|undefined { return new TypeWrapper(this.tsType, this.context); }
get container(): Symbol|undefined { return undefined; }
get callable(): boolean { return true; }
get nullable(): boolean { return false; }
get public(): boolean { return true; }
get definition(): Definition|undefined {
const symbol = this.tsType.getSymbol();
return symbol ? definitionFromTsSymbol(symbol) : undefined;
@ -613,7 +607,7 @@ function findClassSymbolInContext(type: StaticSymbol, context: TypeContext): ts.
}
class EmptyTable implements SymbolTable {
get size(): number { return 0; }
public readonly size: number = 0;
get(key: string): Symbol|undefined { return undefined; }
has(key: string): boolean { return false; }
values(): Symbol[] { return []; }