-
Notifications
You must be signed in to change notification settings - Fork 235
feat(roc): add roc queries #593
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(anon_fun_expr | ||
(expr_body) @function.inner | ||
) @function.outer | ||
|
||
(argument_patterns | ||
((_) @parameter.inner . ","? @parameter.outer) @parameter.outer | ||
) | ||
|
||
(function_type | ||
((_) @parameter.inner . ","? @parameter.outer) @parameter.outer(#not-eq? @parameter.inner "->") | ||
|
||
) | ||
|
||
(function_call_expr | ||
. | ||
(_) | ||
(parenthesized_expr (expr_body) @parameter.inner) @parameter.outer | ||
) | ||
|
||
(function_call_expr | ||
. | ||
(_) ((_) @parameter.inner) @parameter.outer | ||
nat-418 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) | ||
|
||
[ | ||
(annotation_type_def ) @class.inner | ||
(alias_type_def ) @class.inner | ||
(opaque_type_def ) @class.inner | ||
] @class.outer | ||
nat-418 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
(apply_type_arg) @parameter.inner | ||
|
||
(line_comment) @comment.outer | ||
(doc_comment) @comment.outer | ||
nat-418 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query makes it so that
@parameter.outer
only matches the comma sometimes (maybe every time?). Can you change this to only have the second outer query which captures everything? Or if that doesn't work you may need#make-range!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what the problem is here. A Roc function looks like this:
or with multiple params:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; if you try it yourself, you'll find that operating on
@parameter.outer
selects only the comma itself, when it should be the entirety of, say,x,
(with or without trailing whitespace). This is why you may need#make-range!
. You can see some examples of other textobject files doing this if you need, this type of query is pretty common across different languages.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for explaining. this is my first foreay into tree-sitter