Skip to content

Commit

Permalink
add: the start of dart lang support (#2671)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sonnyvesali and pre-commit-ci-lite[bot] authored Nov 9, 2024
1 parent 4362f67 commit 762f377
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 0 deletions.
19 changes: 19 additions & 0 deletions data/fixtures/scopes/dart/ifStatement.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
foo() {
if (true) { }
}
---

[Content] =
[Domain] = 1:2-1:15
>-------------<
1| if (true) { }

[Removal] = 1:0-1:15
>---------------<
1| if (true) { }

[Leading delimiter] = 1:0-1:2
>--<
1| if (true) { }

[Insertion delimiter] = "\n"
17 changes: 17 additions & 0 deletions data/fixtures/scopes/dart/list.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
final list = [1,2,3];
---

[Content] =
[Domain] = 0:13-0:20
>-------<
0| final list = [1,2,3];

[Removal] = 0:12-0:20
>--------<
0| final list = [1,2,3];

[Leading delimiter] = 0:12-0:13
>-<
0| final list = [1,2,3];

[Insertion delimiter] = " "
25 changes: 25 additions & 0 deletions data/fixtures/scopes/dart/map.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
final map = {
'hi': 1,
};
---

[Content] =
[Domain] = 0:14-2:3
>-
0| final map = {
1| 'hi': 1,
2| };
---<

[Removal] = 0:13-2:3
>--
0| final map = {
1| 'hi': 1,
2| };
---<

[Leading delimiter] = 0:13-0:14
>-<
0| final map = {

[Insertion delimiter] = " "
9 changes: 9 additions & 0 deletions data/playground/dart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
foo() {
if (true) {}

final list = [1, 2, 3];

final map = {
'hi': 1,
};
}
11 changes: 11 additions & 0 deletions packages/common/src/scopeSupportFacets/dart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types";
import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;

export const dartScopeSupport: LanguageScopeSupportFacetMap = {
ifStatement: supported,
list: supported,
map: supported,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { clojureScopeSupport } from "./clojure";
import { cppScopeSupport } from "./cpp";
import { csharpScopeSupport } from "./csharp";
import { cssScopeSupport } from "./css";
import { dartScopeSupport } from "./dart";
import { goScopeSupport } from "./go";
import { htmlScopeSupport } from "./html";
import { javaScopeSupport } from "./java";
Expand Down Expand Up @@ -35,6 +36,7 @@ export const languageScopeSupport: StringRecord<LanguageScopeSupportFacetMap> =
cpp: cppScopeSupport,
csharp: csharpScopeSupport,
css: cssScopeSupport,
dart: dartScopeSupport,
go: goScopeSupport,
html: htmlScopeSupport,
java: javaScopeSupport,
Expand Down
5 changes: 5 additions & 0 deletions packages/cursorless-org-docs/src/docs/user/languages/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Language from "./Language";

# dart

<Language languageId="dart"></Language>
18 changes: 18 additions & 0 deletions queries/dart.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

;;!! if () {}
;;! ^^^^^^^^
(if_statement) @ifStatement

;;!! [ 0 ]
;;! ^^^^^
[
(list_literal)
(list_pattern)
] @list

;;!! { value: 0 }
;;! ^^^^^^^^^^^^
[
(set_or_map_literal)
(map_pattern)
] @map

0 comments on commit 762f377

Please sign in to comment.