aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorJoey Hain2023-11-06 01:54:25 +0000
committerGitHub2023-11-06 01:54:25 +0000
commitf73e9a8d15fd5a87d472a49808baf42ba403f9bf (patch)
treec57d8b378ef5877a5f2894b2dc6845b28bffdbbf /runtime
parenta98ad137f9b0678ce9770aaa56a8bf8ca7c51d17 (diff)
highlights: add type.parameter scope to several more languages (#8718)
* typescript * go * haskell * ocaml * kotlin (+ bugfix)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/_typescript/highlights.scm2
-rw-r--r--runtime/queries/_typescript/locals.scm17
-rw-r--r--runtime/queries/go/highlights.scm16
-rw-r--r--runtime/queries/go/locals.scm12
-rw-r--r--runtime/queries/haskell/highlights.scm2
-rw-r--r--runtime/queries/kotlin/highlights.scm5
-rw-r--r--runtime/queries/kotlin/locals.scm15
-rw-r--r--runtime/queries/ocaml/highlights.scm2
8 files changed, 63 insertions, 8 deletions
diff --git a/runtime/queries/_typescript/highlights.scm b/runtime/queries/_typescript/highlights.scm
index a83b4347..f9a67266 100644
--- a/runtime/queries/_typescript/highlights.scm
+++ b/runtime/queries/_typescript/highlights.scm
@@ -107,6 +107,8 @@
; Types
; -----
+(type_parameter
+ name: (type_identifier) @type.parameter)
(type_identifier) @type
(predefined_type) @type.builtin
diff --git a/runtime/queries/_typescript/locals.scm b/runtime/queries/_typescript/locals.scm
index fe13f21d..041ad59d 100644
--- a/runtime/queries/_typescript/locals.scm
+++ b/runtime/queries/_typescript/locals.scm
@@ -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.
@@ -14,3 +26,8 @@
; (i?: t = 1) // Invalid but still posible to hihglight.
(optional_parameter
(identifier) @local.definition)
+
+; References
+;-----------
+
+(type_identifier) @local.reference
diff --git a/runtime/queries/go/highlights.scm b/runtime/queries/go/highlights.scm
index b45a11be..fba2df99 100644
--- a/runtime/queries/go/highlights.scm
+++ b/runtime/queries/go/highlights.scm
@@ -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
@@ -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
diff --git a/runtime/queries/go/locals.scm b/runtime/queries/go/locals.scm
index aae56257..14a6f3e4 100644
--- a/runtime/queries/go/locals.scm
+++ b/runtime/queries/go/locals.scm
@@ -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)
@@ -27,4 +35,4 @@
(identifier) @local.reference
(field_identifier) @local.reference
-
+(type_identifier) @local.reference
diff --git a/runtime/queries/haskell/highlights.scm b/runtime/queries/haskell/highlights.scm
index 18c57c93..3d416de8 100644
--- a/runtime/queries/haskell/highlights.scm
+++ b/runtime/queries/haskell/highlights.scm
@@ -124,7 +124,7 @@
;; Types
(type) @type
-(type_variable) @type
+(type_variable) @type.parameter
(constructor) @constructor
diff --git a/runtime/queries/kotlin/highlights.scm b/runtime/queries/kotlin/highlights.scm
index 208a673f..5b19f849 100644
--- a/runtime/queries/kotlin/highlights.scm
+++ b/runtime/queries/kotlin/highlights.scm
@@ -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
diff --git a/runtime/queries/kotlin/locals.scm b/runtime/queries/kotlin/locals.scm
new file mode 100644
index 00000000..752ed995
--- /dev/null
+++ b/runtime/queries/kotlin/locals.scm
@@ -0,0 +1,15 @@
+; Scopes
+
+[
+ (class_declaration)
+ (function_declaration)
+] @local.scope
+
+; Definitions
+
+(type_parameter
+ (type_identifier) @local.definition)
+
+; References
+
+(type_identifier) @local.reference
diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm
index a08b1267..9d3bf4c8 100644
--- a/runtime/queries/ocaml/highlights.scm
+++ b/runtime/queries/ocaml/highlights.scm
@@ -8,6 +8,8 @@
[(class_name) (class_type_name) (type_constructor)] @type
+(type_variable) @type.parameter
+
[(constructor_name) (tag)] @constructor
; Functions