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

highlights: add type.parameter scope to several more languages #8718

Merged
merged 5 commits into from
Nov 6, 2023
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
2 changes: 2 additions & 0 deletions runtime/queries/_typescript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
; Types
; -----

(type_parameter
name: (type_identifier) @type.parameter)
(type_identifier) @type
(predefined_type) @type.builtin

Expand Down
17 changes: 17 additions & 0 deletions runtime/queries/_typescript/locals.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
; Scopes
;-------

[
(type_alias_declaration)
(class_declaration)
(interface_declaration)
] @local.scope

; Definitions
;------------

(type_parameter
name: (type_identifier) @local.definition)

; Javascript and Typescript Treesitter grammars deviate when defining the
; tree structure for parameters, so we need to address them in each specific
; language instead of ecma.
Expand All @@ -14,3 +26,8 @@
; (i?: t = 1) // Invalid but still posible to hihglight.
(optional_parameter
(identifier) @local.definition)

; References
;-----------

(type_identifier) @local.reference
16 changes: 12 additions & 4 deletions runtime/queries/go/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
function: (selector_expression
field: (field_identifier) @function.method))


; Types

(type_parameter_list
(parameter_declaration
name: (identifier) @type.parameter))

((type_identifier) @type.builtin
(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)$"))

(type_identifier) @type

; Function definitions

(function_declaration
Expand All @@ -30,10 +42,6 @@
(parameter_declaration (identifier) @variable.parameter)
(variadic_parameter_declaration (identifier) @variable.parameter)

((type_identifier) @type.builtin
(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)$"))

(type_identifier) @type
(type_spec
name: (type_identifier) @constructor)
(field_identifier) @variable.other.member
Expand Down
12 changes: 10 additions & 2 deletions runtime/queries/go/locals.scm
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
; Scopes

(block) @local.scope
[
(function_declaration)
(type_declaration)
(block)
] @local.scope

; Definitions

(type_parameter_list
(parameter_declaration
name: (identifier) @local.definition))

(parameter_declaration (identifier) @local.definition)
(variadic_parameter_declaration (identifier) @local.definition)

Expand All @@ -27,4 +35,4 @@

(identifier) @local.reference
(field_identifier) @local.reference

(type_identifier) @local.reference
2 changes: 1 addition & 1 deletion runtime/queries/haskell/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
;; Types

(type) @type
(type_variable) @type
(type_variable) @type.parameter

(constructor) @constructor

Expand Down
5 changes: 4 additions & 1 deletion runtime/queries/kotlin/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@
. (identifier)) @namespace

((type_identifier) @type.builtin
(#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)$"))
(#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)$"))

(type_parameter
(type_identifier) @type.parameter)

(type_identifier) @type

Expand Down
15 changes: 15 additions & 0 deletions runtime/queries/kotlin/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; Scopes

[
(class_declaration)
(function_declaration)
] @local.scope

; Definitions

(type_parameter
(type_identifier) @local.definition)

; References

(type_identifier) @local.reference
2 changes: 2 additions & 0 deletions runtime/queries/ocaml/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[(class_name) (class_type_name) (type_constructor)] @type

(type_variable) @type.parameter

[(constructor_name) (tag)] @constructor

; Functions
Expand Down
Loading