Skip to content

Commit

Permalink
feat: add extra nodes for members and named_argument
Browse files Browse the repository at this point in the history
This is for properly supporting textobject queries
  • Loading branch information
mfelsche authored and amaanq committed Apr 25, 2023
1 parent 5be42c8 commit 9251b9e
Show file tree
Hide file tree
Showing 11 changed files with 100,960 additions and 101,458 deletions.
64 changes: 30 additions & 34 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,35 @@ module.exports = grammar({
optional($.string),
),

members: $ => choice(
repeat1($.field),
repeat1(
choice(
$.constructor,
$.method,
$.behavior,
),
),
seq(
repeat1($.field),
repeat1(
choice(
$.constructor,
$.method,
$.behavior,
),
),
),
),

actor_definition: $ => seq(
'actor',
optional($.annotation),
$.identifier,
optional($.generic_parameters),
optional(seq('is', $.type)),
optional($.string),
repeat($.field),
repeat(choice(
$.constructor,
$.method,
$.behavior,
)),
optional($.members),
),

class_definition: $ => seq(
Expand All @@ -117,12 +133,7 @@ module.exports = grammar({
optional($.generic_parameters),
optional(seq('is', $.type)),
optional($.string),
repeat($.field),
repeat(choice(
$.constructor,
$.method,
$.behavior,
)),
optional($.members),
),

primitive_definition: $ => seq(
Expand All @@ -132,10 +143,7 @@ module.exports = grammar({
optional($.generic_parameters),
optional(seq('is', $.type)),
optional($.string),
repeat(choice(
$.constructor,
$.method,
)),
optional($.members),
),

interface_definition: $ => seq(
Expand All @@ -146,11 +154,7 @@ module.exports = grammar({
optional($.generic_parameters),
optional(seq('is', $.type)),
optional($.string),
repeat(choice(
$.constructor,
$.method,
$.behavior,
)),
optional($.members),
),

trait_definition: $ => seq(
Expand All @@ -161,11 +165,7 @@ module.exports = grammar({
optional($.generic_parameters),
optional(seq('is', $.type)),
optional($.string),
repeat(choice(
$.constructor,
$.method,
$.behavior,
)),
optional($.members),
),

struct_definition: $ => seq(
Expand All @@ -176,11 +176,7 @@ module.exports = grammar({
optional($.generic_parameters),
optional(seq('is', $.type)),
optional($.string),
repeat($.field),
repeat(choice(
$.constructor,
$.method,
)),
optional($.members),
),

field: $ => seq(
Expand Down Expand Up @@ -453,8 +449,9 @@ module.exports = grammar({

named_arguments: $ => seq(
'where',
commaSep(seq($.identifier, '=', $.expression)),
commaSep($.named_argument),
),
named_argument: $ => seq($.identifier, '=', $.expression),

lambda_expression: $ => seq(
optional('@'),
Expand Down Expand Up @@ -675,8 +672,7 @@ module.exports = grammar({
'object',
optional($.capability),
optional(seq('is', $.type)),
repeat($.field),
repeat(choice($.method, $.behavior)),
optional($.members),
'end',
),

Expand Down
1 change: 1 addition & 0 deletions queries/tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(trait_definition (identifier) @name) @definition.interface
(interface_definition (identifier) @name) @definition.interface

(constructor (identifier) @name) @definition.method
(method (identifier) @name) @definition.method
(behavior (identifier) @name) @definition.method

Expand Down
Loading

0 comments on commit 9251b9e

Please sign in to comment.