diff --git a/data/fixtures/scopes/dart/class.scope b/data/fixtures/scopes/dart/class.scope new file mode 100644 index 0000000000..9b0eef7978 --- /dev/null +++ b/data/fixtures/scopes/dart/class.scope @@ -0,0 +1,15 @@ +class MyClass { + +} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| +2| } + -< + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/dart/className.scope b/data/fixtures/scopes/dart/className.scope new file mode 100644 index 0000000000..587c9e2102 --- /dev/null +++ b/data/fixtures/scopes/dart/className.scope @@ -0,0 +1,29 @@ +class MyClass { + +} +--- + +[Content] = 0:6-0:13 + >-------< +0| class MyClass { + +[Removal] = 0:6-0:14 + >--------< +0| class MyClass { + +[Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass { + +[Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass { + +[Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| +2| } + -< + +[Insertion delimiter] = " " diff --git a/data/playground/dart.dart b/data/playground/dart.dart index 93cc1f6a94..d62599aff9 100644 --- a/data/playground/dart.dart +++ b/data/playground/dart.dart @@ -1,5 +1,14 @@ foo() { - if (true) {} + final hi = ''; + if (hi.isNotEmpty) { + + // + } + + + else if (true) { + // + } final list = [1, 2, 3]; @@ -7,3 +16,7 @@ foo() { 'hi': 1, }; } + +class Something{ + +} \ No newline at end of file diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index 9ba7239305..aeb0a213af 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -8,4 +8,6 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { ifStatement: supported, list: supported, map: supported, + class: supported, + className: supported, }; diff --git a/queries/dart.scm b/queries/dart.scm index f9d5e26430..26a6c331b0 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -1,4 +1,3 @@ - ;;!! if () {} ;;! ^^^^^^^^ (if_statement) @ifStatement @@ -16,3 +15,9 @@ (set_or_map_literal) (map_pattern) ] @map + +;;!! class Foo {} +;;! ^^^^^^^^^^^^ +(class_definition + name: (_) @className +) @class @className.domain