Skip to content

Commit 254f630

Browse files
Migrate type
1 parent 83a72af commit 254f630

File tree

2 files changed

+46
-22
lines changed

2 files changed

+46
-22
lines changed

packages/cursorless-engine/src/languages/scala.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ const nodeMatchers: Partial<
2626
),
2727

2828
// *[type] does not work here because while we want most of these we don't want "compound" types,
29-
// eg `generic_type[type]`, because that will grab just the inner generic (the String of List[String])
30-
// and as a rule we want to grab entire type definitions.
31-
type: leadingMatcher(
32-
[
33-
"upper_bound[type]",
34-
"lower_bound[type]",
35-
"view_bound[type]",
36-
"context_bound[type]",
37-
"val_definition[type]",
38-
"val_declaration[type]",
39-
"var_definition[type]",
40-
"var_declaration[type]",
41-
"type_definition",
42-
"extends_clause[type]",
43-
"class_parameter[type]",
44-
"parameter[type]",
45-
"function_definition[return_type]",
46-
"typed_pattern[type]",
47-
"binding[type]",
48-
],
49-
[":"],
50-
),
29+
// // eg `generic_type[type]`, because that will grab just the inner generic (the String of List[String])
30+
// // and as a rule we want to grab entire type definitions.
31+
// type: leadingMatcher(
32+
// [
33+
// "upper_bound[type]",
34+
// "lower_bound[type]",
35+
// "view_bound[type]",
36+
// "context_bound[type]",
37+
// "val_definition[type]",
38+
// "val_declaration[type]",
39+
// "var_definition[type]",
40+
// "var_declaration[type]",
41+
// "type_definition",
42+
// "extends_clause[type]",
43+
// "class_parameter[type]",
44+
// "parameter[type]",
45+
// "function_definition[return_type]",
46+
// "typed_pattern[type]",
47+
// "binding[type]",
48+
// ],
49+
// [":"],
50+
// ),
5151
// value: leadingMatcher(
5252
// ["*[value]", "*[default_value]", "type_definition[type]"],
5353
// ["="],

queries/scala.scm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@
7777
value: (_) @value
7878
) @_.domain
7979

80+
;;!! type Vector = (Int, Int)
81+
;;! ^^^^^^^^^^^^^^^^^^^^^^^^
82+
(type_definition) @type
83+
84+
;;!! def str(bar: String)
85+
;;! ^^^^^^
86+
;;!! val foo: String = "foo"
87+
;;! ^^^^^^
88+
(
89+
(_
90+
(_) @_.leading.endOf
91+
.
92+
type: (_) @type
93+
) @_.domain
94+
(#not-type? @_.domain type_definition)
95+
)
96+
97+
;;!! def str(): String = "bar"
98+
;;! ^^^^^^
99+
(function_definition
100+
(parameters) @_.leading.endOf
101+
return_type: (_) @type
102+
) @_.domain
103+
80104
operator: (operator_identifier) @disqualifyDelimiter
81105
(enumerator
82106
"<-" @disqualifyDelimiter

0 commit comments

Comments
 (0)