Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: the start of dart lang support #2671

Merged
merged 13 commits into from
Nov 9, 2024
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
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
Loading