Skip to content

Commit a7a6139

Browse files
committed
Add additional Query API typedefs based on Elm Language Server's overrides
1 parent 5056950 commit a7a6139

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/binding_web/tree-sitter-web.d.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ declare module 'web-tree-sitter' {
4848
) => string | null;
4949

5050
export interface SyntaxNode {
51+
id: number;
5152
tree: Tree;
5253
type: string;
5354
isNamed: boolean;
@@ -136,10 +137,23 @@ declare module 'web-tree-sitter' {
136137
query(source: string): Query;
137138
}
138139

140+
interface QueryResult {
141+
pattern: number;
142+
captures: { name: string; node: SyntaxNode }[];
143+
}
144+
145+
interface PredicateResult {
146+
operator: string;
147+
operands: { name: string; type: string }[];
148+
}
149+
139150
class Query {
151+
captureNames: string[];
152+
140153
delete(): void;
141-
matches(node: SyntaxNode, startPosition?: Point, endPosition?: Point);
142-
captures(node: SyntaxNode, startPosition?: Point, endPosition?: Point);
154+
matches(node: SyntaxNode, startPosition?: Point, endPosition?: Point): QueryResult[];
155+
captures(node: SyntaxNode, startPosition?: Point, endPosition?: Point): QueryResult[];
156+
predicatesForPattern(patternIndex: number): PredicateResult[];
143157
}
144158
}
145159

0 commit comments

Comments
 (0)