Convert getInsertNodeAfterOptionsWorker to switch statement (#25128)
This commit is contained in:
parent
e200e68178
commit
7a73c89c57
1 changed files with 18 additions and 15 deletions
|
@ -490,22 +490,25 @@ namespace ts.textChanges {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
private getInsertNodeAfterOptionsWorker(node: Node): InsertNodeOptions {
|
private getInsertNodeAfterOptionsWorker(node: Node): InsertNodeOptions {
|
||||||
if (isClassDeclaration(node) || isModuleDeclaration(node)) {
|
switch (node.kind) {
|
||||||
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
|
case SyntaxKind.ClassDeclaration:
|
||||||
|
case SyntaxKind.ModuleDeclaration:
|
||||||
|
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
|
||||||
|
|
||||||
|
case SyntaxKind.VariableDeclaration:
|
||||||
|
case SyntaxKind.StringLiteral:
|
||||||
|
return { prefix: ", " };
|
||||||
|
|
||||||
|
case SyntaxKind.PropertyAssignment:
|
||||||
|
return { suffix: "," + this.newLineCharacter };
|
||||||
|
|
||||||
|
case SyntaxKind.Parameter:
|
||||||
|
return {};
|
||||||
|
|
||||||
|
default:
|
||||||
|
Debug.assert(isStatement(node) || isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it
|
||||||
|
return { suffix: this.newLineCharacter };
|
||||||
}
|
}
|
||||||
else if (isStatement(node) || isClassOrTypeElement(node)) {
|
|
||||||
return { suffix: this.newLineCharacter };
|
|
||||||
}
|
|
||||||
else if (isVariableDeclaration(node) || isStringLiteral(node)) {
|
|
||||||
return { prefix: ", " };
|
|
||||||
}
|
|
||||||
else if (isPropertyAssignment(node)) {
|
|
||||||
return { suffix: "," + this.newLineCharacter };
|
|
||||||
}
|
|
||||||
else if (isParameter(node)) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public insertName(sourceFile: SourceFile, node: FunctionExpression | ClassExpression | ArrowFunction, name: string): void {
|
public insertName(sourceFile: SourceFile, node: FunctionExpression | ClassExpression | ArrowFunction, name: string): void {
|
||||||
|
|
Loading…
Reference in a new issue