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 dart class support #2677

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions data/fixtures/scopes/dart/class.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MyClass {

}
---

[Content] =
[Removal] =
[Domain] = 0:0-2:1
>---------------
0| class MyClass {
1|
2| }
-<

[Insertion delimiter] = "\n\n"
23 changes: 23 additions & 0 deletions data/fixtures/scopes/dart/className.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class MyClass {

}
---

[Content] =
[Domain] = 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 {

[Insertion delimiter] = " "
15 changes: 14 additions & 1 deletion data/playground/dart.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
foo() {
if (true) {}
final hi = '';
if (hi.isNotEmpty) {

//
}


else if (true) {
//
}

final list = [1, 2, 3];

final map = {
'hi': 1,
};
}

class Something{

}
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/dart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = {
ifStatement: supported,
list: supported,
map: supported,
class: supported,
className: supported,
};
14 changes: 14 additions & 0 deletions queries/dart.scm
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@
(set_or_map_literal)
(map_pattern)
] @map

;;!! class Foo {}
;;! ^^^^^^^^^^^^
(
[
(class_definition
name: (_) @className
)
(class_definition

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this empty line shouldn't appear. Have you installed all the recommended extensions? In particular, Andreas's vscode extension should autoformat .scm files. Though maybe you need to configure it to be the formatter for .scm files?

name: (_) @className
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have two of these?

] @class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The domain of class name should be the whole class, so that you can say "class name" from anywhere in the class

Note you'll need to rerun update fixtures after this change

Suggested change
] @class
] @class @className.domain

)
Loading