UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

61 lines (60 loc) 2.12 kB
import * as ts from "typescript"; import { SourceFile } from "./../file"; import { Node } from "./../common"; import { Program } from "./Program"; import { ReferencedSymbol, DefinitionInfo, RenameLocation } from "./results"; export declare class LanguageService { private readonly _compilerObject; private readonly sourceFiles; 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 sourceFile - Source file. * @param node - Node. */ getDefinitions(sourceFile: SourceFile, node: Node): DefinitionInfo[]; /** * Gets the definitions at the specified position. * @param sourceFile - Source file. * @param pos - Position. */ getDefinitionsAtPosition(sourceFile: SourceFile, pos: number): DefinitionInfo[]; /** * Finds references based on the specified node. * @param sourceFile - Source file. * @param node - Node to find references for. */ findReferences(sourceFile: SourceFile, 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[]; }