aboutsummaryrefslogtreecommitdiffstats
path: root/queries/rust/injections.scm
blob: 629f707c72e45cec018f5d778dd51e58c41b0439 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(macro_invocation
  macro:
    [
      (scoped_identifier
        name: (_) @_macro_name)
      (identifier) @_macro_name
    ]
  (token_tree) @injection.content
  (#not-eq? @_macro_name "slint")
  (#set! injection.language "rust")
  (#set! injection.include-children))

(macro_invocation
  macro:
    [
      (scoped_identifier
        name: (_) @_macro_name)
      (identifier) @_macro_name
    ]
  (token_tree) @injection.content
  (#eq? @_macro_name "slint")
  (#offset! @injection.content 0 1 0 -1)
  (#set! injection.language "slint")
  (#set! injection.include-children))

(macro_definition
  (macro_rule
    left: (token_tree_pattern) @injection.content
    (#set! injection.language "rust")))

(macro_definition
  (macro_rule
    right: (token_tree) @injection.content
    (#set! injection.language "rust")))

([
  (line_comment)
  (block_comment)
] @injection.content
  (#set! injection.language "comment"))

((macro_invocation
  macro: (identifier) @injection.language
  (token_tree) @injection.content)
  (#any-of? @injection.language "html" "json"))

(call_expression
  function:
    (scoped_identifier
      path: (identifier) @_regex
      (#any-of? @_regex "Regex" "ByteRegexBuilder")
      name: (identifier) @_new
      (#eq? @_new "new"))
  arguments:
    (arguments
      (raw_string_literal) @injection.content)
  (#set! injection.language "regex"))

(call_expression
  function:
    (scoped_identifier
      path:
        (scoped_identifier
          (identifier) @_regex
          (#any-of? @_regex "Regex" "ByteRegexBuilder") .)
      name: (identifier) @_new
      (#eq? @_new "new"))
  arguments:
    (arguments
      (raw_string_literal) @injection.content)
  (#set! injection.language "regex"))

(call_expression
  function:
    (scoped_identifier
      path: (identifier) @_regex
      (#any-of? @_regex "RegexSet" "RegexSetBuilder")
      name: (identifier) @_new
      (#eq? @_new "new"))
  arguments:
    (arguments
      (array_expression
        (raw_string_literal) @injection.content))
  (#set! injection.language "regex"))

(call_expression
  function:
    (scoped_identifier
      path:
        (scoped_identifier
          (identifier) @_regex
          (#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
      name: (identifier) @_new
      (#eq? @_new "new"))
  arguments:
    (arguments
      (array_expression
        (raw_string_literal) @injection.content))
  (#set! injection.language "regex"))

((block_comment) @injection.content
  (#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
  (#set! injection.language "re2c"))