on master help sign in
highlights: add type.parameter scope to several more languages (#8718)
f73e9a8Joey Hain
runtime/queries/_typescript/highlights.scm+2
@@ -107,6 +107,8 @@
107; Types
107; Types
108; -----
108; -----
109
109
110+(type_parameter
111+ name: (type_identifier) @type.parameter)
110(type_identifier) @type
112(type_identifier) @type
111(predefined_type) @type.builtin
113(predefined_type) @type.builtin
112
114
runtime/queries/_typescript/locals.scm+17
@@ -1,6 +1,18 @@
1+; Scopes
2+;-------
3+
4+[
5+ (type_alias_declaration)
6+ (class_declaration)
7+ (interface_declaration)
8+] @local.scope
9+
1; Definitions
10; Definitions
2;------------
11;------------
3
12
13+(type_parameter
14+ name: (type_identifier) @local.definition)
15+
4; Javascript and Typescript Treesitter grammars deviate when defining the
16; Javascript and Typescript Treesitter grammars deviate when defining the
5; tree structure for parameters, so we need to address them in each specific
17; tree structure for parameters, so we need to address them in each specific
6; language instead of ecma.
18; language instead of ecma.
@@ -14,3 +26,8 @@
14; (i?: t = 1) // Invalid but still posible to hihglight.
26; (i?: t = 1) // Invalid but still posible to hihglight.
15(optional_parameter
27(optional_parameter
16 (identifier) @local.definition)
28 (identifier) @local.definition)
29+
30+; References
31+;-----------
32+
33+(type_identifier) @local.reference
runtime/queries/go/highlights.scm+12−4
@@ -11,6 +11,18 @@
11 function: (selector_expression
11 function: (selector_expression
12 field: (field_identifier) @function.method))
12 field: (field_identifier) @function.method))
13
13
14+
15+; Types
16+
17+(type_parameter_list
18+ (parameter_declaration
19+ name: (identifier) @type.parameter))
20+
21+((type_identifier) @type.builtin
22+ (match? @type.builtin "^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$"))
23+
24+(type_identifier) @type
25+
14; Function definitions
26; Function definitions
15
27
16(function_declaration
28(function_declaration
@@ -30,10 +42,6 @@
30(parameter_declaration (identifier) @variable.parameter)
42(parameter_declaration (identifier) @variable.parameter)
31(variadic_parameter_declaration (identifier) @variable.parameter)
43(variadic_parameter_declaration (identifier) @variable.parameter)
32
44
33−((type_identifier) @type.builtin
34− (match? @type.builtin "^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$"))
35−
36−(type_identifier) @type
37(type_spec
45(type_spec
38 name: (type_identifier) @constructor)
46 name: (type_identifier) @constructor)
39(field_identifier) @variable.other.member
47(field_identifier) @variable.other.member
runtime/queries/go/locals.scm+10−2
@@ -1,9 +1,17 @@
1; Scopes
1; Scopes
2
2
3+[
4+ (function_declaration)
5+ (type_declaration)
6+ (block)
3−(block) @local.scope
7+] @local.scope
4
8
5; Definitions
9; Definitions
6
10
11+(type_parameter_list
12+ (parameter_declaration
13+ name: (identifier) @local.definition))
14+
7(parameter_declaration (identifier) @local.definition)
15(parameter_declaration (identifier) @local.definition)
8(variadic_parameter_declaration (identifier) @local.definition)
16(variadic_parameter_declaration (identifier) @local.definition)
9
17
@@ -27,4 +35,4 @@
27
35
28(identifier) @local.reference
36(identifier) @local.reference
29(field_identifier) @local.reference
37(field_identifier) @local.reference
30−
38+(type_identifier) @local.reference
runtime/queries/haskell/highlights.scm+1−1
@@ -124,7 +124,7 @@
124;; Types
124;; Types
125
125
126(type) @type
126(type) @type
127−(type_variable) @type
127+(type_variable) @type.parameter
128
128
129(constructor) @constructor
129(constructor) @constructor
130
130
runtime/queries/kotlin/highlights.scm+4−1
@@ -244,7 +244,10 @@
244 . (identifier)) @namespace
244 . (identifier)) @namespace
245
245
246((type_identifier) @type.builtin
246((type_identifier) @type.builtin
247− (#match? @function.builtin "^(Byte|Short|Int|Long|UByte|UShort|UInt|ULong|Float|Double|Boolean|Char|String|Array|ByteArray|ShortArray|IntArray|LongArray|UByteArray|UShortArray|UIntArray|ULongArray|FloatArray|DoubleArray|BooleanArray|CharArray|Map|Set|List|EmptyMap|EmptySet|EmptyList|MutableMap|MutableSet|MutableList)$"))
247+ (#match? @type.builtin "^(Byte|Short|Int|Long|UByte|UShort|UInt|ULong|Float|Double|Boolean|Char|String|Array|ByteArray|ShortArray|IntArray|LongArray|UByteArray|UShortArray|UIntArray|ULongArray|FloatArray|DoubleArray|BooleanArray|CharArray|Map|Set|List|EmptyMap|EmptySet|EmptyList|MutableMap|MutableSet|MutableList)$"))
248+
249+(type_parameter
250+ (type_identifier) @type.parameter)
248
251
249(type_identifier) @type
252(type_identifier) @type
250
253
runtime/queries/kotlin/locals.scmnew file+15
@@ -0,0 +1,15 @@
1+; Scopes
2+
3+[
4+ (class_declaration)
5+ (function_declaration)
6+] @local.scope
7+
8+; Definitions
9+
10+(type_parameter
11+ (type_identifier) @local.definition)
12+
13+; References
14+
15+(type_identifier) @local.reference
runtime/queries/ocaml/highlights.scm+2
@@ -8,6 +8,8 @@
8
8
9[(class_name) (class_type_name) (type_constructor)] @type
9[(class_name) (class_type_name) (type_constructor)] @type
10
10
11+(type_variable) @type.parameter
12+
11[(constructor_name) (tag)] @constructor
13[(constructor_name) (tag)] @constructor
12
14
13; Functions
15; Functions