Skip to content

Commit 762f377

Browse files
add: the start of dart lang support (#2671)
Hello, hopefully I did these first steps right and I would like some rough guidance on adding the subsequent things like snippets or any other essentials for dart support, thanks! ## 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 --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 4362f67 commit 762f377

File tree

8 files changed

+106
-0
lines changed

8 files changed

+106
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
foo() {
2+
if (true) { }
3+
}
4+
---
5+
6+
[Content] =
7+
[Domain] = 1:2-1:15
8+
>-------------<
9+
1| if (true) { }
10+
11+
[Removal] = 1:0-1:15
12+
>---------------<
13+
1| if (true) { }
14+
15+
[Leading delimiter] = 1:0-1:2
16+
>--<
17+
1| if (true) { }
18+
19+
[Insertion delimiter] = "\n"

data/fixtures/scopes/dart/list.scope

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
final list = [1,2,3];
2+
---
3+
4+
[Content] =
5+
[Domain] = 0:13-0:20
6+
>-------<
7+
0| final list = [1,2,3];
8+
9+
[Removal] = 0:12-0:20
10+
>--------<
11+
0| final list = [1,2,3];
12+
13+
[Leading delimiter] = 0:12-0:13
14+
>-<
15+
0| final list = [1,2,3];
16+
17+
[Insertion delimiter] = " "

data/fixtures/scopes/dart/map.scope

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
final map = {
2+
'hi': 1,
3+
};
4+
---
5+
6+
[Content] =
7+
[Domain] = 0:14-2:3
8+
>-
9+
0| final map = {
10+
1| 'hi': 1,
11+
2| };
12+
---<
13+
14+
[Removal] = 0:13-2:3
15+
>--
16+
0| final map = {
17+
1| 'hi': 1,
18+
2| };
19+
---<
20+
21+
[Leading delimiter] = 0:13-0:14
22+
>-<
23+
0| final map = {
24+
25+
[Insertion delimiter] = " "

data/playground/dart.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
foo() {
2+
if (true) {}
3+
4+
final list = [1, 2, 3];
5+
6+
final map = {
7+
'hi': 1,
8+
};
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types";
2+
import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types";
3+
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5+
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
6+
7+
export const dartScopeSupport: LanguageScopeSupportFacetMap = {
8+
ifStatement: supported,
9+
list: supported,
10+
map: supported,
11+
};

packages/common/src/scopeSupportFacets/languageScopeSupport.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { clojureScopeSupport } from "./clojure";
44
import { cppScopeSupport } from "./cpp";
55
import { csharpScopeSupport } from "./csharp";
66
import { cssScopeSupport } from "./css";
7+
import { dartScopeSupport } from "./dart";
78
import { goScopeSupport } from "./go";
89
import { htmlScopeSupport } from "./html";
910
import { javaScopeSupport } from "./java";
@@ -35,6 +36,7 @@ export const languageScopeSupport: StringRecord<LanguageScopeSupportFacetMap> =
3536
cpp: cppScopeSupport,
3637
csharp: csharpScopeSupport,
3738
css: cssScopeSupport,
39+
dart: dartScopeSupport,
3840
go: goScopeSupport,
3941
html: htmlScopeSupport,
4042
java: javaScopeSupport,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Language from "./Language";
2+
3+
# dart
4+
5+
<Language languageId="dart"></Language>

queries/dart.scm

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
;;!! if () {}
3+
;;! ^^^^^^^^
4+
(if_statement) @ifStatement
5+
6+
;;!! [ 0 ]
7+
;;! ^^^^^
8+
[
9+
(list_literal)
10+
(list_pattern)
11+
] @list
12+
13+
;;!! { value: 0 }
14+
;;! ^^^^^^^^^^^^
15+
[
16+
(set_or_map_literal)
17+
(map_pattern)
18+
] @map

0 commit comments

Comments
 (0)