Skip to content

Commit 0e266f0

Browse files
Migrate json scopes (#2042)
## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent 5b22a22 commit 0e266f0

File tree

7 files changed

+36
-45
lines changed

7 files changed

+36
-45
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import csharp from "./csharp";
1515
import go from "./go";
1616
import { patternMatchers as html } from "./html";
1717
import java from "./java";
18-
import { patternMatchers as json } from "./json";
1918
import latex from "./latex";
2019
import markdown from "./markdown";
2120
import php from "./php";
@@ -64,8 +63,6 @@ export const languageMatchers: Record<
6463
java,
6564
javascript: typescript,
6665
javascriptreact: typescript,
67-
json,
68-
jsonc: json,
6966
latex,
7067
markdown,
7168
php,

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { getNodeInternalRange, getNodeRange } from "../util/nodeSelectors";
66
import { LegacyLanguageId } from "./LegacyLanguageId";
77
import { getNodeMatcher } from "./getNodeMatcher";
88
import { stringTextFragmentExtractor as htmlStringTextFragmentExtractor } from "./html";
9-
import { stringTextFragmentExtractor as jsonStringTextFragmentExtractor } from "./json";
109
import { stringTextFragmentExtractor as rubyStringTextFragmentExtractor } from "./ruby";
1110
import { stringTextFragmentExtractor as scssStringTextFragmentExtractor } from "./scss";
1211
import { stringTextFragmentExtractor as typescriptStringTextFragmentExtractor } from "./typescript";
@@ -140,14 +139,6 @@ const textFragmentExtractors: Record<
140139
"javascriptreact",
141140
typescriptStringTextFragmentExtractor,
142141
),
143-
jsonc: constructDefaultTextFragmentExtractor(
144-
"jsonc",
145-
jsonStringTextFragmentExtractor,
146-
),
147-
json: constructDefaultTextFragmentExtractor(
148-
"json",
149-
jsonStringTextFragmentExtractor,
150-
),
151142
latex: fullDocumentTextFragmentExtractor,
152143
markdown: fullDocumentTextFragmentExtractor,
153144
ruby: constructDefaultTextFragmentExtractor(

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

Lines changed: 0 additions & 32 deletions
This file was deleted.

packages/cursorless-engine/src/runIntegrationTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function assertNoScopesBothLegacyAndNew(
2828
for (const languageId of legacyLanguageIds) {
2929
await treeSitter.loadLanguage(languageId);
3030

31-
unsafeKeys(languageMatchers[languageId]).map((scopeTypeType) => {
31+
unsafeKeys(languageMatchers[languageId] ?? {}).map((scopeTypeType) => {
3232
if (
3333
languageDefinitions.get(languageId)?.getScopeHandler({
3434
type: scopeTypeType,

queries/json.scm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
;;!! "string"
2+
;;! ^^^^^^
3+
(string_content) @textFragment
4+
5+
;;!! {"value": 0}
6+
;;! ^^^^^^^^^^^^
7+
(object) @map
8+
9+
;;!! [0]
10+
;;! ^^^
11+
(array) @list
12+
13+
;;!! "string"
14+
;;! ^^^^^^^^
15+
(string) @string
16+
17+
;;!! {"value": 0}
18+
;;! ^^^^^^^ ^
19+
;;! ----------
20+
(pair
21+
key: (_) @collectionKey @collectionKey.trailing.start.endOf @value.leading.start.endOf
22+
value: (_) @value @collectionKey.trailing.end.startOf @value.leading.end.startOf
23+
) @_.domain
24+
25+
;;!! {"bbb": 0, "ccc": 0}
26+
;;! ******************
27+
(object
28+
"{" @collectionKey.iteration.start.endOf @value.iteration.start.endOf
29+
"}" @collectionKey.iteration.end.startOf @value.iteration.end.startOf
30+
)

queries/jsonc.scm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
;; import json.scm
2+
3+
;; Currently not supported by our Tree sitter parser
4+
;; (comment) @comment @textFragment

queries/jsonl.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
;; import json.scm

0 commit comments

Comments
 (0)