UNPKG

@lpc-lang/core

Version:
218 lines 14.5 kB
import { ArrayBindingElement, AssertionExpression, BindingElement, BreakOrContinueStatement, CallChain, CallExpression, CallLikeExpression, ClassElement, ClassLikeDeclaration, CompilerOptions, ConciseBody, Declaration, DeclarationName, DeclarationWithTypeParameters, Diagnostic, EntityName, Expression, FileReference, FunctionLikeDeclaration, HasExpressionInitializer, HasModifiers, Identifier, IterationStatement, JSDocClassTag, JSDocComment, JSDocDeprecatedTag, JSDocImplementsTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocParameterTag, JSDocPropertyLikeTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSignature, JSDocTag, JSDocTemplateTag, JSDocThisTag, JSDocThrowsTag, JSDocTypeTag, KeywordSyntaxKind, LeftHandSideExpression, LiteralExpression, MemberName, Modifier, ModifierFlags, Node, NodeArray, NodeFlags, ParameterDeclaration, PropertyAccessExpression, PropertyName, QualifiedName, SignatureDeclaration, SortedReadonlyArray, Statement, StringLiteral, StringLiteralLike, Symbol, SyntaxKind, TextChangeRange, TextSpan, TypeElement, TypeNode, TypeParameterDeclaration, VariableDeclaration } from "./_namespaces/lpc.js"; export declare function symbolName(symbol: Symbol): string; export declare function idText(identifierOrPrivateName: Identifier): string; /** * Gets a value indicating whether a node originated in the parse tree. * * @param node The node to test. */ export declare function isParseTreeNode(node: Node): boolean; /** * Gets the original parse tree node for a node. * * @param node The original node. * @returns The original parse tree node if found; otherwise, undefined. */ export declare function getParseTreeNode(node: Node | undefined): Node | undefined; /** * Gets the original parse tree node for a node. * * @param node The original node. * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. * @returns The original parse tree node if found; otherwise, undefined. */ export declare function getParseTreeNode<T extends Node>(node: T | undefined, nodeTest?: (node: Node) => node is T): T | undefined; export declare function isFunctionLike(node: Node | undefined): node is SignatureDeclaration; export declare function getCombinedNodeFlags(node: Node): NodeFlags; export declare function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; export declare function skipPartiallyEmittedExpressions(node: Expression): Expression; export declare function skipPartiallyEmittedExpressions(node: Node): Node; export declare function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; export declare function isCallOrNewExpression(node: Node): node is CallExpression; /** * Node test that determines whether a node is a valid type node. * This differs from the `isPartOfTypeNode` function which determines whether a node is *part* * of a TypeNode. */ export declare function isTypeNode(node: Node): node is TypeNode; /** Gets the JSDoc deprecated tag for the node if present */ export declare function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined; /** Gets the JSDoc deprecated tag for the node if present */ export declare function getDeprecatedModifierOrJSDocTag(node: Node): JSDocDeprecatedTag | Modifier | undefined; /** * Iterates through the parent chain of a node and performs the callback on each parent until the callback * returns a truthy value, then returns that value. * If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit" * At that point findAncestor returns undefined. */ export declare function findAncestor<T extends Node>(node: Node | undefined, callback: (element: Node) => element is T): T | undefined; export declare function findAncestor(node: Node | undefined, callback: (element: Node) => boolean | "quit"): Node | undefined; export declare function isCallLikeExpression(node: Node): node is CallLikeExpression; export declare function isIterationStatement(node: Node, lookInLabeledStatements: false): node is IterationStatement; export declare function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; export declare function isArrayBindingElement(node: Node): node is ArrayBindingElement; export declare function isStatement(node: Node): node is Statement; export declare function getCombinedModifierFlags(node: Declaration): ModifierFlags; /** * Determines whether a node is an expression based only on its kind. */ export declare function isExpression(node: Node): node is Expression; /** * If the text of an Identifier matches a keyword (including contextual and TypeScript-specific keywords), returns the * SyntaxKind for the matching keyword. */ export declare function identifierToKeywordKind(node: Identifier): KeywordSyntaxKind | undefined; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ export declare function isToken(n: Node): boolean; /** * True if kind is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ export declare function isTokenKind(kind: SyntaxKind): boolean; export declare function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain; /** True if node is of a kind that may contain comment text. */ export declare function isJSDocCommentContainingNode(node: Node): boolean; export declare function isMemberName(node: Node): node is MemberName; export declare function textSpanEnd(span: TextSpan): number; export declare function createTextSpan(start: number, length: number): TextSpan; export declare function createTextSpanFromBounds(start: number, end: number): TextSpan; export declare function isBreakOrContinueStatement(node: Node): node is BreakOrContinueStatement; export declare function isEntityName(node: Node): node is EntityName; export declare function isCallChain(node: Node): node is CallChain; export declare function isPropertyName(node: Node): node is PropertyName; export declare function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName; export declare function getOriginalNode(node: Node): Node; export declare function getOriginalNode<T extends Node>(node: Node, nodeTest: (node: Node) => node is T): T; export declare function getOriginalNode(node: Node | undefined): Node | undefined; export declare function getOriginalNode<T extends Node>(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined; export declare function isLiteralExpression(node: Node): node is LiteralExpression; /** True if has initializer node attached to it. */ export declare function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer; export declare function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean; export declare function isByRefParameterDeclaration(node: ParameterDeclaration | JSDocParameterTag): node is ParameterDeclaration; export declare function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean; export declare function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; export declare function isClassLike(node: Node): node is ClassLikeDeclaration; export declare function isConciseBody(node: Node): node is ConciseBody; export declare function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; export declare const unchangedTextChangeRange: TextChangeRange; /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will * have a text change from V1 to V2, V2 to V3, ..., Vn. * * This function will then merge those changes into a single change range valid between V1 and * Vn. */ export declare function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; export declare function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: readonly T[]): SortedReadonlyArray<T>; export declare function getDefaultLibFolder(options: CompilerOptions): string; export declare function getDefaultLibFileName(options: CompilerOptions): string; export declare function isExternalModuleNameRelative(moduleName: string): boolean; export declare function isStringTextContainingNode(node: Node): node is StringLiteral; export declare function isTypeElement(node: Node): node is TypeElement; export declare function isStringLiteralLike(node: Node | FileReference): node is StringLiteralLike; export declare function isModifier(node: Node): node is Modifier; /** Get all JSDoc tags related to a node, including those on parent nodes. */ export declare function getJSDocTags(node: Node): readonly JSDocTag[]; export declare function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; export declare function isClassElement(node: Node): node is ClassElement; export declare function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement; /** * Gets the JSDoc parameter tags for the node if present. * * @remarks Returns any JSDoc param tag whose name matches the provided * parameter, whether a param tag on a containing function * expression, or a param tag on a variable declaration whose * initializer is the containing function. The tags closest to the * node are returned first, so in the previous example, the param * tag on the containing function expression would be first. * * For binding patterns, parameter tags are matched by position. */ export declare function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the type node for the node if provided via JSDoc. * * @remarks The search includes any JSDoc param tag that relates * to the provided parameter, for example a type tag on the * parameter itself, or a param tag on a containing function * expression, or a param tag on a variable declaration whose * initializer is the containing function. The tags closest to the * node are examined first, so in the previous example, the type * tag directly on the node would be returned. */ export declare function getJSDocType(node: Node): TypeNode | undefined; export declare function isAssertionExpression(node: Node): node is AssertionExpression; /** * Gets the JSDoc type parameter tags for the node if present. * * @remarks Returns any JSDoc template tag whose names match the provided * parameter, whether a template tag on a containing function * expression, or a template tag on a variable declaration whose * initializer is the containing function. The tags closest to the * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ export declare function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; export declare function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; export declare function getModifiers(node: HasModifiers): readonly Modifier[] | undefined; /** Gets the JSDoc type tag for the node if present and valid */ export declare function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined; /** Gets the JSDoc this tag for the node if present */ export declare function getJSDocThisTag(node: Node): JSDocThisTag | undefined; export declare function getJSDocThrowsTag(node: Node): JSDocThrowsTag | undefined; /** Gets all JSDoc tags that match a specified predicate */ export declare function getAllJSDocTags<T extends JSDocTag>(node: Node, predicate: (tag: JSDocTag) => tag is T): readonly T[]; /** Gets the JSDoc implements tags for the node if present */ export declare function getJSDocImplementsTags(node: Node): readonly JSDocImplementsTag[]; export declare function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; export declare function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; /** Gets the JSDoc return tag for the node if present */ export declare function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined; /** * Gets the return type node for the node if provided via JSDoc return tag or type tag. * * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function * gets the type from inside the braces, after the fat arrow, etc. */ export declare function getJSDocReturnType(node: Node): TypeNode | undefined; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. * * This does *not* return type parameters from a jsdoc reference to a generic type, eg * * type Id = <T>(x: T) => T * /** @type {Id} / * function id(x) { return x } */ export declare function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; /** Gets the JSDoc class tag for the node if present */ export declare function getJSDocClassTag(node: Node): JSDocClassTag | undefined; /** * Return true if the node has JSDoc parameter tags. * * @remarks Includes parameter tags that are not directly on the node, * for example on a variable declaration whose initializer is a function expression. */ export declare function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean; export declare function getJSDocSatisfiesTag(node: Node): JSDocSatisfiesTag | undefined; /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. */ export declare function validateLocaleAndSetLanguage(locale: string, sys: { getExecutingFilePath(): string; resolvePath(path: string): string; fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; }, errors?: Diagnostic[]): void; /** Gets the text of a jsdoc comment, flattening links to their text. */ export declare function getTextOfJSDocComment(comment?: string | NodeArray<JSDocComment>): string; //# sourceMappingURL=utilitiesPublic.d.ts.map