Skip to content

Commit a3ec9aa

Browse files
Cleanup
1 parent 087e5bf commit a3ec9aa

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ export class TreeSitterQuery {
7373
end?: Position,
7474
): QueryMatch[] {
7575
if (!treeSitterQueryCache.isValid(document, start, end)) {
76-
const matches = this.getAllmatches(document, start, end);
76+
const matches = this.getAllMatches(document, start, end);
7777
treeSitterQueryCache.update(document, start, end, matches);
7878
}
7979
return treeSitterQueryCache.get();
8080
}
8181

82-
private getAllmatches(
82+
private getAllMatches(
8383
document: TextDocument,
8484
start?: Position,
8585
end?: Position,

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

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ export class Cache {
99
private endPosition: Position | undefined;
1010
private matches: QueryMatch[] = [];
1111

12+
clear() {
13+
this.documentUri = "";
14+
this.documentVersion = -1;
15+
this.documentLanguageId = "";
16+
this.startPosition = undefined;
17+
this.endPosition = undefined;
18+
this.matches = [];
19+
}
20+
1221
isValid(
1322
document: TextDocument,
1423
startPosition: Position | undefined,
@@ -42,31 +51,4 @@ export class Cache {
4251
}
4352
}
4453

45-
let cache = new Cache();
46-
47-
export const treeSitterQueryCache = {
48-
isValid(
49-
document: TextDocument,
50-
startPosition: Position | undefined,
51-
endPosition: Position | undefined,
52-
) {
53-
return cache.isValid(document, startPosition, endPosition);
54-
},
55-
56-
update(
57-
document: TextDocument,
58-
startPosition: Position | undefined,
59-
endPosition: Position | undefined,
60-
matches: QueryMatch[],
61-
) {
62-
cache.update(document, startPosition, endPosition, matches);
63-
},
64-
65-
get() {
66-
return cache.get();
67-
},
68-
69-
clear() {
70-
cache = new Cache();
71-
},
72-
};
54+
export const treeSitterQueryCache = new Cache();

0 commit comments

Comments
 (0)