Skip to content

Commit

Permalink
Fix existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilios1995 committed Mar 24, 2024
1 parent 9fcd6e8 commit 10be739
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 48 deletions.
14 changes: 11 additions & 3 deletions queries/rescript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@
body: (function))

; function calls

; neovim and tree-sitter-cli handle conflicts differently:
; in tree-sitter-cli the first match wins, while in neovim the last match does.
; to get the desired result for `raise` in both, we put it before the general function call
; queries (for the CLI), but also add a priority metadata rule (for neovim).

(call_expression
function: (value_identifier) @keyword.exception
(#set! "priority" 105)
(#eq? @keyword.exception "raise"))

(call_expression
function: (value_identifier_path
_
Expand Down Expand Up @@ -181,9 +192,6 @@
"catch"
] @keyword.exception

(call_expression
function: (value_identifier) @keyword.exception
(#eq? @keyword.exception "raise"))

[
"for"
Expand Down
4 changes: 2 additions & 2 deletions test/highlight/decorators.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@name
//<- annotation
//<- attribute

@@name
//<- annotation
//<- attribute
22 changes: 11 additions & 11 deletions test/highlight/expressions.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@ foo->bar == +x +. 1.0
// ^ property

switch foo {
// <- conditional
// <- keyword.conditional
| list{1, x, ...rest} =>
//^ type
// ^ number
// ^ parameter
// ^ variable.parameter
// ^ punctuation.special
// ^ parameter
// ^ punctuation.special
// ^ variable.parameter
// ^ operator
42
| list{1, 2, ...list{b, ..._} as rest} => rest
// ^ parameter
// ^ variable.parameter
// ^ variable
| exception Js.Exn.Error(_) => 99
//^ exception
//^ keyword.exception
}

switch bar {
| #...Mod.t => 33
//^ constant
//^ constructor
}

{ foo, bar: baz, qux: 1 }
//^ property
// ^ property

exception InputClosed(string)
//<- exception
//<- keyword.exception

raise(InputClosed("The stream has closed!"))
//<- exception
//<- keyword.exception

try {
//<- exception
//<- keyword.exception
someOtherJSFunctionThatThrows()
} catch {
// ^ exception
// ^ keyword.exception
| Not_found => 1 // catch a ReScript exception
| Invalid_argument(_) => 2 // catch a second ReScript exception
| Js.Exn.Error(obj) => 3 // catch the JS exception
Expand Down
10 changes: 5 additions & 5 deletions test/highlight/functions.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
let inc = n => n + 1
// ^ parameter
// ^ variable.parameter
// ^ punctuation.special

let fn = (a, (b, c), {d, e}, [f, g]) => a + b + c + d + e + f + g
// ^ parameter
// ^ parameter
// ^ parameter
// ^ parameter
// ^ variable.parameter
// ^ variable.parameter
// ^ variable.parameter
// ^ variable.parameter

let uncurry = (. u, .x) => (u, x)
// ^ operator
Expand Down
26 changes: 13 additions & 13 deletions test/highlight/literals.res
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@

/**/ #polyvar
// ^ constant
// ^ constant
// ^ constructor
// ^ constructor

/**/ #"polyvar"
// ^ constant
// ^ constant
// ^ constant
// ^ constructor
// ^ constructor
// ^ constructor

/**/ #\"polyvar"
// ^ constant
// ^ constant
// ^ constant
// ^ constant
// ^ constructor
// ^ constructor
// ^ constructor
// ^ constructor

/**/ #77
// ^ constant
// ^ constant
// ^ constructor
// ^ constructor

/**/ 'R'
// ^ string.special
// ^ string.special
// ^ character
// ^ character

/**/ '\\'
// ^ string.escape
20 changes: 10 additions & 10 deletions test/highlight/modules.res
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

@@warning("-27")
//<- annotation
//^annotation
//<- attribute
//^attribute
// ^ string

include NumericCurve({
// ^ include
// ^ namespace
// ^ keyword.import
// ^ module
let foo = foo
})

let {baz, _} = module(User.Inner)
// ^ keyword
// ^ namespace
// ^ namespace
// ^ module
// ^ module

module Belt = {
include (Belt: module type of Belt with module Map := Belt.Map and module Result := Belt.Result)
// ^ include
// ^ keyword.import
// ^ keyword
// ^ keyword
// ^ operator
Expand All @@ -29,7 +29,7 @@ let a = module(
type t
let hello = "Hello"
}: X
// ^ namespace
// ^ module
)

module B = unpack(a)
Expand All @@ -46,5 +46,5 @@ module A: A = {
}

let packedA = module(A: A)
// ^ namespace
// ^ namespace
// ^ module
// ^ module
8 changes: 4 additions & 4 deletions test/highlight/type_declarations.res
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

type rec t =
//<- keyword
// ^ keyword
//<- keyword.type
// ^ keyword.modifier
// ^ type
| Node(t, t)
// ^ constant
// ^ constructor
// ^ type
| Terminal
// ^ constant
// ^ constructor
| Component(module(Foo.t))
// ^ keyword

Expand Down

0 comments on commit 10be739

Please sign in to comment.