import type { Language, Point, Query, QueryCapture, Tree } from 'web-tree-sitter'; import type { TreeSitterLanguageName } from '../languages'; export type Comment = { start: Point; end: Point; content: string; capture: QueryCapture; }; export type CommentResolution = { commentAtCursor: Comment; commentAboveCursor?: never; } | { commentAtCursor?: never; commentAboveCursor: Comment; }; export declare class CommentResolver { #private; protected queryByLanguage: Map; constructor(); /** * Returns the comment that is on or directly above the cursor, if it exists. * To handle the case the comment may be several new lines above the cursor, * we traverse the tree to check if any nodes are between the comment and the cursor. */ getCommentForCursor({ languageName, tree, cursorPosition, treeSitterLanguage, }: { languageName: TreeSitterLanguageName; tree: Tree; treeSitterLanguage: Language; cursorPosition: Point; }): CommentResolution | undefined; /** * Returns the total number of lines that are comments in a parsed syntax tree. * Uses a Set because we only want to count each line once. * @param {Object} params - Parameters for counting comment lines. * @param {TreeSitterLanguageName} params.languageName - The name of the programming language. * @param {Tree} params.tree - The syntax tree to analyze. * @param {Language} params.treeSitterLanguage - The Tree-sitter language instance. * @returns {number} - The total number of unique lines containing comments. */ getTotalCommentLines({ treeSitterLanguage, languageName, tree, }: { languageName: TreeSitterLanguageName; treeSitterLanguage: Language; tree: Tree; }): number; static isCommentEmpty(comment: Comment): boolean; } export declare function getCommentResolver(): CommentResolver;