simplify and inline methods

This commit is contained in:
Arthur Ozga
2016-12-14 09:10:51 -08:00
parent 4b02099372
commit 8be881916b
3 changed files with 7 additions and 19 deletions

View File

@@ -96,7 +96,6 @@ namespace ts {
getTypeAtLocation: getTypeOfNode,
getPropertySymbolOfDestructuringAssignment,
signatureToString,
indexSignatureToString,
typeToString,
getSymbolDisplayBuilder,
symbolToString,
@@ -2037,15 +2036,6 @@ namespace ts {
return result;
}
function indexSignatureToString(info: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node): string {
const writer = getSingleLineStringWriter();
getSymbolDisplayBuilder().buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration);
const result = writer.string();
releaseStringWriter(writer);
return result;
}
function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
const writer = getSingleLineStringWriter();
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);

View File

@@ -2353,7 +2353,6 @@ namespace ts {
getTypeAtLocation(node: Node): Type;
getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type;
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
indexSignatureToString(info: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node): string;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
createSymbol(flags: SymbolFlags, name: string): Symbol;

View File

@@ -29,7 +29,7 @@ namespace ts.codefix {
// Note that this is ultimately derived from a map indexed by symbol names,
// so duplicates cannot occur.
const implementedTypeSymbols = checker.getPropertiesOfType(implementedType);
const nonPrivateMembers = implementedTypeSymbols.filter(symbolRefersToNonPrivateMember);
const nonPrivateMembers = implementedTypeSymbols.filter(symbol => !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private));
let insertion = getMissingIndexSignatureInsertion(implementedType, IndexKind.Number, classDecl, hasNumericIndexSignature);
insertion += getMissingIndexSignatureInsertion(implementedType, IndexKind.String, classDecl, hasStringIndexSignature);
@@ -47,18 +47,17 @@ namespace ts.codefix {
if (!hasIndexSigOfKind) {
const IndexInfoOfKind = checker.getIndexInfoOfType(type, kind);
if (IndexInfoOfKind) {
return checker.indexSignatureToString(IndexInfoOfKind, kind, enclosingDeclaration);
const writer = getSingleLineStringWriter();
checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration);
const result = writer.string();
releaseStringWriter(writer);
return result;
}
}
return "";
}
function symbolRefersToNonPrivateMember(symbol: Symbol): boolean {
const decls = symbol.getDeclarations();
Debug.assert(!!(decls && decls.length > 0));
return !(getModifierFlags(decls[0]) & ModifierFlags.Private);
}
function pushAction(result: CodeAction[], insertion: string, description: string): void {
const newAction: CodeAction = {
description: description,