diff --git a/data/fixtures/scopes/dart/ifStatement.scope b/data/fixtures/scopes/dart/ifStatement.scope new file mode 100644 index 0000000000..09ee23aab9 --- /dev/null +++ b/data/fixtures/scopes/dart/ifStatement.scope @@ -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" diff --git a/data/fixtures/scopes/dart/list.scope b/data/fixtures/scopes/dart/list.scope new file mode 100644 index 0000000000..169cc3d024 --- /dev/null +++ b/data/fixtures/scopes/dart/list.scope @@ -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] = " " diff --git a/data/fixtures/scopes/dart/map.scope b/data/fixtures/scopes/dart/map.scope new file mode 100644 index 0000000000..bc293e112f --- /dev/null +++ b/data/fixtures/scopes/dart/map.scope @@ -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] = " " diff --git a/data/playground/dart.dart b/data/playground/dart.dart new file mode 100644 index 0000000000..93cc1f6a94 --- /dev/null +++ b/data/playground/dart.dart @@ -0,0 +1,9 @@ +foo() { + if (true) {} + + final list = [1, 2, 3]; + + final map = { + 'hi': 1, + }; +} diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts new file mode 100644 index 0000000000..9ba7239305 --- /dev/null +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -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, +}; diff --git a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts index 8e9d706b59..2c05c76c6b 100644 --- a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts +++ b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts @@ -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"; @@ -35,6 +36,7 @@ export const languageScopeSupport: StringRecord = cpp: cppScopeSupport, csharp: csharpScopeSupport, css: cssScopeSupport, + dart: dartScopeSupport, go: goScopeSupport, html: htmlScopeSupport, java: javaScopeSupport, diff --git a/packages/cursorless-org-docs/src/docs/user/languages/dart.mdx b/packages/cursorless-org-docs/src/docs/user/languages/dart.mdx new file mode 100644 index 0000000000..fe37a25c4f --- /dev/null +++ b/packages/cursorless-org-docs/src/docs/user/languages/dart.mdx @@ -0,0 +1,5 @@ +import Language from "./Language"; + +# dart + + diff --git a/queries/dart.scm b/queries/dart.scm new file mode 100644 index 0000000000..f9d5e26430 --- /dev/null +++ b/queries/dart.scm @@ -0,0 +1,18 @@ + +;;!! if () {} +;;! ^^^^^^^^ +(if_statement) @ifStatement + +;;!! [ 0 ] +;;! ^^^^^ +[ + (list_literal) + (list_pattern) +] @list + +;;!! { value: 0 } +;;! ^^^^^^^^^^^^ +[ + (set_or_map_literal) + (map_pattern) +] @map