Merge pull request #787 from wingrunr21/add_ts_query_support
Update TS definitions to support the Query API
This commit is contained in:
commit
2d339de5d0
1 changed files with 29 additions and 3 deletions
32
lib/binding_web/tree-sitter-web.d.ts
vendored
32
lib/binding_web/tree-sitter-web.d.ts
vendored
|
|
@ -37,7 +37,7 @@ declare module 'web-tree-sitter' {
|
|||
|
||||
export type Logger = (
|
||||
message: string,
|
||||
params: {[param: string]: string},
|
||||
params: { [param: string]: string },
|
||||
type: "parse" | "lex"
|
||||
) => void;
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ declare module 'web-tree-sitter' {
|
|||
) => string | null;
|
||||
|
||||
export interface SyntaxNode {
|
||||
id: number;
|
||||
tree: Tree;
|
||||
type: string;
|
||||
isNamed: boolean;
|
||||
|
|
@ -131,8 +132,33 @@ declare module 'web-tree-sitter' {
|
|||
readonly version: number;
|
||||
readonly fieldCount: number;
|
||||
|
||||
fieldNameForId(fieldId: number): string | null
|
||||
fieldIdForName(fieldName: string): number | null
|
||||
fieldNameForId(fieldId: number): string | null;
|
||||
fieldIdForName(fieldName: string): number | null;
|
||||
query(source: string): Query;
|
||||
}
|
||||
|
||||
interface QueryCapture {
|
||||
name: string;
|
||||
node: SyntaxNode;
|
||||
}
|
||||
|
||||
interface QueryMatch {
|
||||
pattern: number;
|
||||
captures: QueryCapture[];
|
||||
}
|
||||
|
||||
interface PredicateResult {
|
||||
operator: string;
|
||||
operands: { name: string; type: string }[];
|
||||
}
|
||||
|
||||
class Query {
|
||||
captureNames: string[];
|
||||
|
||||
delete(): void;
|
||||
matches(node: SyntaxNode, startPosition?: Point, endPosition?: Point): QueryMatch[];
|
||||
captures(node: SyntaxNode, startPosition?: Point, endPosition?: Point): QueryCapture[];
|
||||
predicatesForPattern(patternIndex: number): PredicateResult[];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue