import { INodeService } from "./i-node-service"; import { Decorator, Node, NodeArray, SourceFile, Statement, SyntaxKind } from "typescript"; import { IDecoratorService } from "../decorator/i-decorator-service"; import { IRemover } from "../../remover/i-remover-base"; import { ITypescriptASTUtil } from "@wessberg/typescript-ast-util"; import { IDecoratorCtor } from "../../light-ast/ctor/decorator/i-decorator-ctor"; import { ITypescriptLanguageService } from "@wessberg/typescript-language-service"; import { IJoiner } from "../../joiner/i-joiner-getter"; import { IUpdater } from "../../updater/i-updater-getter"; /** * An abstract Service for working with Nodes */ export declare abstract class NodeService implements INodeService { protected decoratorService: IDecoratorService; protected languageService: ITypescriptLanguageService; protected joiner: IJoiner; protected updater: IUpdater; protected remover: IRemover; protected astUtil: ITypescriptASTUtil; /** * The allowed SyntaxKinds when parsing a SourceFile for relevant Expressions * @type {SyntaxKind[]} */ protected abstract readonly ALLOWED_KINDS: Iterable; constructor(decoratorService: IDecoratorService, languageService: ITypescriptLanguageService, joiner: IJoiner, updater: IUpdater, remover: IRemover, astUtil: ITypescriptASTUtil); /** * Gets all Nodes for the provided file * @template T * @param {string} file * @param {string} [content] * @param {boolean} [deep] * @returns {NodeArray} */ getAllForFile(file: string, content?: string, deep?: boolean): NodeArray; /** * Gets all Nods for the provided SourceFile * @template T * @param {SourceFile|Statement[]|NodeArray|Statement} sourceFile * @param {boolean} [deep] * @returns {NodeArray} */ getAll(sourceFile: SourceFile | Statement[] | NodeArray | Statement, deep?: boolean): NodeArray; /** * Adds the given decorator to the given node * @template T * @param {string | IDecoratorCtor | Decorator} decorator * @param {T} node * @returns {T} */ addDecorator(decorator: string | IDecoratorCtor | Decorator, node: T): T; /** * Returns true if the node has a decorator matching the provided one * @template T * @param {string | IDecoratorCtor | RegExp} decorator * @param {T} node * @returns {boolean} */ hasDecorator(decorator: string | IDecoratorCtor | RegExp, node: T): boolean; /** * Returns the decorator matching the provided one on the Node * @template T * @param {string | IDecoratorCtor | RegExp} decorator * @param {T} node * @returns {Decorator|undefined} */ getDecorator(decorator: string | IDecoratorCtor | RegExp, node: T): Decorator | undefined; /** * Removes all matching decorators from the node. If a second argument isn't provided, all decorators will be removed. * @template T * @param {T} node * @param {(string | IDecoratorCtor | RegExp | Decorator)[]} decorators * @returns {boolean} */ removeDecorators(node: T, decorators?: (string | IDecoratorCtor | RegExp | Decorator)[]): boolean; /** * Removes the provided decorator from the MethodDeclaration, if it has it * @template T * @param {string | IDecoratorCtor | RegExp | Decorator} decorator * @param {T} node * @returns {boolean} */ removeDecorator(decorator: string | IDecoratorCtor | RegExp | Decorator, node: T): boolean; }