UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

94 lines (93 loc) 3.47 kB
import * as ts from "typescript"; import { SourceFile } from "./../file"; import { Node } from "./../common"; import { Program } from "./Program"; import { FormatCodeSettings } from "./inputs"; import { ReferencedSymbol, DefinitionInfo, RenameLocation, ImplementationLocation, TextChange, EmitOutput } from "./results"; export declare class LanguageService { private readonly _compilerObject; private readonly compilerHost; private program; /** * Gets the compiler language service. */ readonly compilerObject: ts.LanguageService; /** * Gets the language service's program. */ getProgram(): Program; /** * Rename the specified node. * @param node - Node to rename. * @param newName - New name for the node. */ renameNode(node: Node, newName: string): void; /** * Rename the provided rename locations. * @param renameLocations - Rename locations. * @param newName - New name for the node. */ renameLocations(renameLocations: RenameLocation[], newName: string): void; /** * Gets the definitions for the specified node. * @param node - Node. */ getDefinitions(node: Node): DefinitionInfo[]; /** * Gets the definitions at the specified position. * @param sourceFile - Source file. * @param pos - Position. */ getDefinitionsAtPosition(sourceFile: SourceFile, pos: number): DefinitionInfo[]; /** * Gets the implementations for the specified node. * @param node - Node. */ getImplementations(node: Node): ImplementationLocation[]; /** * Gets the implementations at the specified position. * @param sourceFile - Source file. * @param pos - Position. */ getImplementationsAtPosition(sourceFile: SourceFile, pos: number): ImplementationLocation[]; /** * Finds references based on the specified node. * @param node - Node to find references for. */ findReferences(node: Node): ReferencedSymbol[]; /** * Finds references based on the specified position. * @param sourceFile - Source file. * @param pos - Position to find the reference at. */ findReferencesAtPosition(sourceFile: SourceFile, pos: number): ReferencedSymbol[]; /** * Find the rename locations for the specified node. * @param node - Node to get the rename locations for. */ findRenameLocations(node: Node): RenameLocation[]; /** * Gets the formatting edits for a document. * @param filePath - File path of the source file. * @param settings - Format code settings. */ getFormattingEditsForDocument(filePath: string, settings: FormatCodeSettings): TextChange[]; /** * Gets the formatted text for a document. * @param filePath - File path of the source file. * @param settings - Format code settings. */ getFormattedDocumentText(filePath: string, settings: FormatCodeSettings): string; /** * Gets the emit output of a source file. * @param sourceFile - Source file. * @param emitOnlyDtsFiles - Whether to only emit the d.ts files. */ getEmitOutput(sourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitOutput; /** * Gets the emit output of a source file. * @param filePath - File path. * @param emitOnlyDtsFiles - Whether to only emit the d.ts files. */ getEmitOutput(filePath: string, emitOnlyDtsFiles?: boolean): EmitOutput; }