nvim-treesitter/tests/query/highlights/julia/test.jl
Fredrik Ekre 3f377c0739 fix(julia): treat :: as operator in type contexts
This patch captures `::` as `@operator` within
`(unary_typed_expression)` and `(typed_expression)`. These should be the
only two cases that the parser can emit when encountering `::` in the
source, but as a fallback it is still captured as `@punctuation` in all
other cases.

The reasons for capturing `::` as an operator are i) the close relation
with the other type-operators `<:` and `>:` and ii) the fact that it is
treated as an operator by the Julia parser, just like `<:` and `>:`.
2024-11-23 11:10:05 +01:00

26 lines
1.1 KiB
Julia

function load_data(::Symbol; ::Int) :: Tuple
# <- @keyword.function
# ^ @function.call
# ^ @punctuation.bracket
# ^^ @operator
# ^ @type.builtin
# ^ @punctuation.delimiter
# ^^ @operator
# ^^^ @type.builtin
# ^ @punctuation.bracket
# ^^ @operator
# ^ @type.builtin
dataset = CIFAR10(; Tx = Float32, split = split)
# ^^^^^^^ @variable
# ^ @operator
# ^ @function.call
# ^ @operator
# ^ @type.builtin
X = reshape(dataset.features[:, :, :, begin:n_obs], :, n_obs) # flattening the image pixels
# ^^^^^ @variable.builtin
y = categorical2onehot(dataset.targets[begin:n_obs], N_LABELS)
# ^^^^^ @variable.builtin
return X, y
# ^^^^^^ @keyword.return
end
# <- @keyword.function