ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
48 lines (47 loc) • 2.06 kB
TypeScript
import CodeBlockWriter from "code-block-writer";
import { Constructor } from "./../../Constructor";
import { Node } from "./../common";
export declare type TextInsertableNodeExtensionType = Node;
export interface TextInsertableNode {
/**
* Inserts text within the body of the node.
*
* WARNING: This will dispose any previously navigated descendant nodes.
* @param pos - Position to insert at.
* @param text - Text to insert.
*/
insertText(pos: number, text: string): this;
/**
* Inserts text within the body of the node using a writer.
*
* WARNING: This will dispose any previously navigated descendant nodes.
* @param pos - Position to insert at.
* @param writerFunction - Write the text using the provided writer.
*/
insertText(pos: number, writerFunction: (writer: CodeBlockWriter) => void): this;
/**
* Replaces text within the body of the node.
*
* WARNING: This will dispose any previously navigated descendant nodes.
* @param range - Start and end position of the text to replace.
* @param text - Text to replace the range with.
*/
replaceText(range: [number, number], text: string): this;
/**
* Replaces text within the body of the node using a writer function.
*
* WARNING: This will dispose any previously navigated descendant nodes.
* @param range - Start and end position of the text to replace.
* @param writerFunction - Write the text using the provided writer.
*/
replaceText(range: [number, number], writerFunction: (writer: CodeBlockWriter) => void): this;
/**
* Removes text within the body of the node.
*
* WARNING: This will dispose any previously navigated descendant nodes.
* @param pos - Start position to remove.
* @param end - End position to remove.
*/
removeText(pos: number, end: number): this;
}
export declare function TextInsertableNode<T extends Constructor<TextInsertableNodeExtensionType>>(Base: T): Constructor<TextInsertableNode> & T;