|
| 1 | +; Core grammar injections |
| 2 | +(embedded_html |
| 3 | + (angled_bracket_fenced_text) @injection.content |
| 4 | + (#set! injection.language "html") |
| 5 | +) |
| 6 | + |
| 7 | +(embedded_sql |
| 8 | + (_ |
| 9 | + (paren_fenced_text) @injection.content |
| 10 | + ) |
| 11 | + (#set! injection.language "sql") |
| 12 | +) |
| 13 | + |
| 14 | + (embedded_js |
| 15 | + [ |
| 16 | + (angled_bracket_fenced_text) |
| 17 | + (embedded_js_special_case) |
| 18 | + ] @injection.content |
| 19 | + (#set! injection.language "javascript")) |
| 20 | + |
| 21 | + |
| 22 | +(embedded_xml |
| 23 | + (angled_bracket_fenced_text) @injection.content |
| 24 | + (#set! injection.language "xml") |
| 25 | +) |
| 26 | + |
| 27 | +([ |
| 28 | + (line_comment_1) |
| 29 | + (line_comment_2) |
| 30 | + (line_comment_3) |
| 31 | + (block_comment) |
| 32 | +] @injection.content |
| 33 | + (#set! injection.language "comment")) |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +; UDL injections |
| 38 | +;; Keywords, one of type language = "python", none of type codemode |
| 39 | +; External method body injection based on [ Language = ... ] |
| 40 | +(method_definition |
| 41 | + (external_method_keywords |
| 42 | + (method_keyword_language |
| 43 | + (rhs) @lang)) |
| 44 | + (external_method_body_content) @injection.content |
| 45 | + (#set! injection.include-children "true") |
| 46 | + (#match? @lang "^[Pp][Yy][Tt][Hh][Oo][Nn]$") |
| 47 | + (#set! injection.language "python")) |
| 48 | + |
| 49 | +(method_definition |
| 50 | + (external_method_keywords |
| 51 | + (method_keyword_language |
| 52 | + (rhs) @lang)) |
| 53 | + (external_method_body_content) @injection.content |
| 54 | + (#set! injection.include-children "true") |
| 55 | + (#match? @lang "^[Tt][Ss][Qq][Ll]$") |
| 56 | + (#set! injection.language "tsql")) |
| 57 | + |
| 58 | +(method_definition |
| 59 | + (external_method_keywords |
| 60 | + (method_keyword_language |
| 61 | + (rhs) @lang)) |
| 62 | + (external_method_body_content) @injection.content |
| 63 | + (#set! injection.include-children "true") |
| 64 | + (#match? @lang "^[Ii][Ss][Pp][Ll]$") |
| 65 | + (#set! injection.language "ispl")) |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +;; External trigger with python body |
| 70 | +( |
| 71 | + (trigger |
| 72 | + (external_trigger |
| 73 | + (trigger_keywords |
| 74 | + (method_keyword_language |
| 75 | + (rhs) @lang)) |
| 76 | + (external_method_body_content) @injection.content)) |
| 77 | + (#set! injection.include-children "true") |
| 78 | + (#match? @lang "^[Pp][Yy][Tt][Hh][Oo][Nn]$") |
| 79 | + (#set! injection.language "python") |
| 80 | +) |
| 81 | + |
| 82 | +;; External trigger with TSQL body |
| 83 | +( |
| 84 | + (trigger |
| 85 | + (external_trigger |
| 86 | + (trigger_keywords |
| 87 | + (method_keyword_language |
| 88 | + (rhs) @lang)) |
| 89 | + (external_method_body_content) @injection.content)) |
| 90 | + (#set! injection.include-children "true") |
| 91 | + (#match? @lang "^[Tt][Ss][Qq][Ll]$") |
| 92 | + (#set! injection.language "tsql") |
| 93 | +) |
| 94 | + |
| 95 | +; A query must be of type %SQLQuery to have an SQL body, otherwise the body |
| 96 | +; is empty |
| 97 | +(query |
| 98 | + (return_type |
| 99 | + (typename |
| 100 | + (identifier) @_querytype |
| 101 | + (#match? @_querytype "^%[Ss][Qq][Ll][Qq][Uu][Ee][Rr][Yy]$"))) |
| 102 | + (query_body |
| 103 | + (query_body_content) @injection.content) |
| 104 | + (#set! injection.language "sql") |
| 105 | + (#set! injection.include-children "true") |
| 106 | +) |
| 107 | + |
| 108 | +; XDATA blocks: |
| 109 | +; - xdata_any requires a keyword list that includes MimeType |
| 110 | +; - xdata_xml allows an optional keyword list and defaults to XML |
| 111 | + |
| 112 | +; ---------------------------- |
| 113 | +; XDATA injections (MimeType) |
| 114 | +; ---------------------------- |
| 115 | + |
| 116 | +; text/markdown |
| 117 | +(xdata |
| 118 | + (xdata_any |
| 119 | + (xdata_keywords |
| 120 | + (xdata_keyword_mimetype (rhs) @mt)) |
| 121 | + (external_method_body_content) @injection.content) |
| 122 | + (#set! injection.include-children "true") |
| 123 | + (#match? @mt "^\"?text/markdown\"?$") |
| 124 | + (#set! injection.language "markdown")) |
| 125 | + |
| 126 | +; XML MimeTypes |
| 127 | +(xdata |
| 128 | + (xdata_any |
| 129 | + (xdata_keywords |
| 130 | + (xdata_keyword_mimetype (rhs) @mt)) |
| 131 | + (external_method_body_content) @injection.content) |
| 132 | + (#set! injection.include-children "true") |
| 133 | + (#match? @mt "^\"?([Tt][Ee][Xx][Tt]|[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn])/[Xx][Mm][Ll]\"?$") |
| 134 | + (#set! injection.language "xml")) |
| 135 | + |
| 136 | +; text/html |
| 137 | +(xdata |
| 138 | + (xdata_any |
| 139 | + (xdata_keywords |
| 140 | + (xdata_keyword_mimetype (rhs) @mt)) |
| 141 | + (external_method_body_content) @injection.content) |
| 142 | + (#set! injection.include-children "true") |
| 143 | + (#match? @mt "^\"?text/html\"?$") |
| 144 | + (#set! injection.language "html")) |
| 145 | + |
| 146 | +; application/json |
| 147 | +(xdata |
| 148 | + (xdata_any |
| 149 | + (xdata_keywords |
| 150 | + (xdata_keyword_mimetype (rhs) @mt)) |
| 151 | + (external_method_body_content) @injection.content) |
| 152 | + (#set! injection.include-children "true") |
| 153 | + (#match? @mt "^\"?application/json\"?$") |
| 154 | + (#set! injection.language "json")) |
| 155 | + |
| 156 | +; text/yaml or application/yaml |
| 157 | +(xdata |
| 158 | + (xdata_any |
| 159 | + (xdata_keywords |
| 160 | + (xdata_keyword_mimetype (rhs) @mt)) |
| 161 | + (external_method_body_content) @injection.content) |
| 162 | + (#set! injection.include-children "true") |
| 163 | + (#match? @mt "^\"?([Tt][Ee][Xx][Tt]|[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn])/[Yy][Aa][Mm][Ll]\"?$") |
| 164 | + (#set! injection.language "yaml")) |
| 165 | + |
| 166 | +; text/css |
| 167 | +(xdata |
| 168 | + (xdata_any |
| 169 | + (xdata_keywords |
| 170 | + (xdata_keyword_mimetype (rhs) @mt)) |
| 171 | + (external_method_body_content) @injection.content) |
| 172 | + (#set! injection.include-children "true") |
| 173 | + (#match? @mt "^\"?text/css\"?$") |
| 174 | + (#set! injection.language "css")) |
| 175 | + |
| 176 | +; ----------------------------------------- |
| 177 | +; XDATA default (no MimeType): XML fallback |
| 178 | +; ----------------------------------------- |
| 179 | +(xdata |
| 180 | + (xdata_xml |
| 181 | + (xdata_keywords)? |
| 182 | + (external_method_body_content) @injection.content) |
| 183 | + (#set! injection.include-children "true") |
| 184 | + (#set! injection.language "xml")) |
| 185 | + |
| 186 | + |
| 187 | +; Storage definition is XML |
| 188 | +(storage |
| 189 | + (storage_body |
| 190 | + (external_method_body_content) @injection.content) |
| 191 | + (#set! injection.language "xml") |
| 192 | + (#set! injection.include-children "true")) |
0 commit comments