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

Improve tree-sitter queries for Scala #9475

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 6 additions & 21 deletions runtime/queries/scala/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,13 @@
(var_declaration
name: (identifier) @variable)

; method definition
; function definitions/declarations

(class_definition
body: (template_body
[
(function_definition
name: (identifier) @function.method)
(function_declaration
name: (identifier) @function.method)
]))
(trait_definition
body: (template_body
[
(function_definition
name: (identifier) @function.method)
(function_declaration
name: (identifier) @function.method)
]))
(object_definition
body: (template_body
(function_definition
name: (identifier) @function.method)))
(function_declaration
name: (identifier) @function.method)

(function_definition
name: (identifier) @function.method)

; imports/exports

Expand Down
10 changes: 8 additions & 2 deletions runtime/queries/scala/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
; Function queries

(function_definition
body: (_) @function.inside) @function.around
body: (_) @function.inside) @function.around ; Does not include end marker

; Does not match block lambdas or Scala 3 braceless lambdas
(lambda_expression
(_) @function.inside) @function.around

; Scala 3 braceless lambda
(colon_argument
(_) @function.inside) @function.around


; Class queries

Expand All @@ -32,6 +35,9 @@
(parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(class_parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(parameter_types
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

Expand Down
Loading