* Replaces the text of an AST node with a new one. * @param oldNode Node to be replaced. * @param newNode New node to be inserted. * @param emitHint Hint when formatting the text of the new node. * @param sourceFileWhenPrinting File to use when printing out the new node. This is importan
(
oldNode: ts.Node,
newNode: ts.Node,
emitHint = ts.EmitHint.Unspecified,
sourceFileWhenPrinting?: ts.SourceFile,
)
| 80 | * without it. |
| 81 | */ |
| 82 | replaceNode( |
| 83 | oldNode: ts.Node, |
| 84 | newNode: ts.Node, |
| 85 | emitHint = ts.EmitHint.Unspecified, |
| 86 | sourceFileWhenPrinting?: ts.SourceFile, |
| 87 | ): void { |
| 88 | const sourceFile = oldNode.getSourceFile(); |
| 89 | this.replaceText( |
| 90 | sourceFile, |
| 91 | oldNode.getStart(), |
| 92 | oldNode.getWidth(), |
| 93 | this._printer.printNode(emitHint, newNode, sourceFileWhenPrinting || sourceFile), |
| 94 | ); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Removes the text of an AST node from a file. |
no test coverage detected