pub const OBJECTSCRIPT_INJECTIONS_QUERY: &str = "; SQL and HTML Injections\n\n(embedded_html\n (angled_bracket_fenced_text) @injection.content\n (#set! injection.language \"html\")\n ;; TODO: Investigate if we can use html as the fallback grammar\n ;; We REALLY need to make it easy for users to bundle all of these\n ;; grammars\n)\n\n(embedded_sql\n (_\n (paren_fenced_text) @injection.content\n )\n (#set! injection.language \"sql\")\n)\n\n(embedded_js\n (angled_bracket_fenced_text) @injection.content\n (#set! injection.language \"javascript\")\n)\n\n(embedded_xml\n (angled_bracket_fenced_text) @injection.content\n (#set! injection.language \"xml\")\n)\n\n([\n (line_comment_1)\n (line_comment_2)\n (line_comment_3)\n (block_comment)\n] @injection.content\n (#set! injection.language \"comment\"))\n\n\n; Target method_body_content and reparse it using\n; objectscript_core\n;\n\n((documatic_line) @injection.content\n (#set! injection.language \"comment\")\n)\n\n;; Keywords, one of type language = \"python\", none of type codemode\n; External method body injection based on [ Language = ... ]\n(method_definition\n keywords: (external_method_keywords\n (method_keyword_language\n (rhs) @lang))\n body: (external_method_body_content) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @lang \"(?i)^python$\")\n (#set! injection.language \"python\"))\n\n(method_definition\n keywords: (external_method_keywords\n (method_keyword_language\n (rhs) @lang))\n body: (external_method_body_content) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @lang \"(?i)^tsql$\")\n (#set! injection.language \"tsql\"))\n\n(method_definition\n keywords: (external_method_keywords\n (method_keyword_language\n (rhs) @lang))\n body: (external_method_body_content) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @lang \"(?i)^javascript$\")\n (#set! injection.language \"ispl\"))\n\n\n\n;; External trigger with python body\n(\n (trigger\n (trigger_keywords\n (method_keyword_language) @lang)\n (external_method_body_content) @injection.content)\n (#match? @lang \"python\")\n (#set! injection.language \"python\")\n)\n\n;; External trigger with TSQL body\n(\n (trigger\n (trigger_keywords\n (method_keyword_language) @lang)\n (external_method_body_content) @injection.content)\n (#match? @lang \"tsql\")\n (#set! injection.language \"tsql\")\n)\n\n; A query must be of type %SQLQuery to have an SQL body, otherwise the body\n; is empty\n(query\n\ttype: (_ (typename (identifier) @_querytype (#eq? @_querytype \"%SQLQuery\")))\n (_ (query_body_content) @injection.content)\n (#set! injection.language \"sql\")\n (#set! injection.include-children \"true\")\n)\n\n; XDATA blocks. There\'s a MimeType keyword that defines the content-type\n; To prevent overlapping matches, we use a different body for the case where\n; no MimeType is given and default to XML, otherwise we extract the language\n; from the mimetype.\n\n; ----------------------------\n; XDATA injections (MimeType)\n; ----------------------------\n\n; text/markdown\n(xdata\n keywords: (xdata_keywords\n (xdata_keyword_mimetype (rhs) @mt))\n body: (xdata_body_content_any) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @mt \"^\\\"text/markdown\\\"$\")\n (#set! injection.language \"markdown\"))\n\n; text/xml\n(xdata\n keywords: (xdata_keywords\n (xdata_keyword_mimetype (rhs) @mt))\n body: (xdata_body_content_any) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @mt \"^\\\"text/xml\\\"$\")\n (#set! injection.language \"xml\"))\n\n; text/html\n(xdata\n keywords: (xdata_keywords\n (xdata_keyword_mimetype (rhs) @mt))\n body: (xdata_body_content_any) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @mt \"^\\\"text/html\\\"$\")\n (#set! injection.language \"html\"))\n\n; application/json\n(xdata\n keywords: (xdata_keywords\n (xdata_keyword_mimetype (rhs) @mt))\n body: (xdata_body_content_any) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @mt \"^\\\"application/json\\\"$\")\n (#set! injection.language \"json\"))\n\n; text/css\n(xdata\n keywords: (xdata_keywords\n (xdata_keyword_mimetype (rhs) @mt))\n body: (xdata_body_content_any) @injection.content\n (#set! injection.include-children \"true\")\n (#match? @mt \"^\\\"text/css\\\"$\")\n (#set! injection.language \"css\"))\n\n; -----------------------------------------\n; XDATA default (no MimeType): XML fallback\n; -----------------------------------------\n(xdata\n body: (xdata_body_content_xml) @injection.content\n (#set! injection.include-children \"true\")\n (#set! injection.language \"xml\"))\n\n\n; NOTE: This should work in tree-sitter, but #strip! seems to not be available\n; in Zed and possibly other environments.\n;\n; Also, it\'s not exactly clear if include-children and combined are needed\n;\n; (xdata\n; keywords:\n; (_\n; (xdata_keyword_mimetype rhs: (_) @injection.language\n; (#match? @injection.language \"^\\\"[A-Za-z0-9.+-]+/[^\\\"/]+\\\"$\")\n; )\n; )\n;\n; (#strip! @injection.language \"^\\\"|\\\"$\") ; strip outer quotes\n; (#strip! @injection.language \"^[^/]+/\") ; drop leading application or text prefix\n; (#strip! @injection.language \"^x-\") ; drop leading x- on the name\n;\n; body: (xdata_body_content_any) @injection.content\n; (#set! injection.include-children \"false\")\n; (#set! injection.combined \"true\")\n; )\n;\n; ; Match an unspecified XDATA -- that is XML\n; (xdata\n; body: (xdata_body_content_xml) @injection.content\n; (#set! injection.language \"xml\")\n; (#set! injection.include-children \"false\")\n; (#set! injection.combined \"true\")\n; )\n\n; Storage definition is XML\n(storage\n body: (_) @injection.content\n (#set! injection.language \"xml\")\n (#set! injection.include-children \"true\")\n)\n\n";Expand description
The injections query for ObjectScript.