Skip to content

Commit 98b02db

Browse files
Simplification
1 parent 56c856a commit 98b02db

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

packages/cursorless-engine/src/languages/TreeSitterQuery/QueryCapture.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ export interface QueryCapture {
4949
hasError(): boolean;
5050
}
5151

52-
/**
53-
* A capture of a query pattern against a syntax tree that can be modified.
54-
*/
55-
export interface ModifiableQueryCapture {
56-
readonly name: string;
57-
range: Range;
58-
allowMultiple: boolean;
59-
insertionDelimiter: string | undefined;
60-
hasError(): boolean;
61-
}
62-
6352
/**
6453
* A match of a query pattern against a syntax tree.
6554
*/

packages/cursorless-engine/src/languages/TreeSitterQuery/TreeSitterQuery.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { Query } from "web-tree-sitter";
55
import { ide } from "../../singletons/ide.singleton";
66
import { getNodeRange } from "../../util/nodeSelectors";
77
import type {
8-
ModifiableQueryCapture,
98
MutableQueryCapture,
109
MutableQueryMatch,
1110
QueryMatch,
@@ -150,10 +149,10 @@ function createQueryMatch(
150149
match: MutableQueryMatch,
151150
isTesting: boolean,
152151
): QueryMatch {
153-
const result: ModifiableQueryCapture[] = [];
152+
const result: MutableQueryCapture[] = [];
154153
const resultMap = new Map<
155154
string,
156-
{ acc: ModifiableQueryCapture; captures: MutableQueryCapture[] }
155+
{ acc: MutableQueryCapture; captures: MutableQueryCapture[] }
157156
>();
158157

159158
// Merge the ranges of all captures with the same name into a single
@@ -168,11 +167,9 @@ function createQueryMatch(
168167

169168
if (existing == null) {
170169
const accumulator = {
170+
...capture,
171171
name,
172172
range,
173-
allowMultiple: capture.allowMultiple,
174-
insertionDelimiter: capture.insertionDelimiter,
175-
hasError: () => capture.hasError(),
176173
};
177174
result.push(accumulator);
178175
resultMap.set(name, {

0 commit comments

Comments
 (0)