Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
id = "objectscript"
name = "InterSystems ObjectScript"
version = "1.1.0"
version = "1.2.0"
schema_version = 1
authors = ["Dave McCaldon <davem@intersystems.com>"]
authors = ["Dave McCaldon <davem@intersystems.com>","Hannah Kimura <hannah.kimura@intersystems.com>"]
description = "InterSystems IRIS ObjectScript Extension"
repository = "https://github.com/intersystems/zed-objectscript"

[grammars.objectscript]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "c0f4461e18d0ac9f4625cddebfeb34ef13f99f8a"
commit = "78f0fdb872bbb65084ee9a0d3ad44093cc913684"
path = "udl"

[grammars.objectscript_core]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "78f0fdb872bbb65084ee9a0d3ad44093cc913684"
path = "core"
167 changes: 167 additions & 0 deletions languages/objectscript/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
; EXPR GRAMMAR HIGHLIGHTS
(pattern_expression) @string.regex
(numeric_literal) @number
(string_literal) @string

(keyword_pound_pound_class) @keyword
(keyword_pound_pound_super) @keyword
(system_defined_variable) @variable.special
(system_defined_function) @variable.special
(sql_field_modifier) @variable.special
(property_name) @property
(method_name) @function
(parameter_name) @property
(class_name) @type
(macro) @constant

(routine_ref) @variable
(sql_field_identifier) @variable
(lvn) @variable
(gvn) @variable
(ssvn) @variable
(instance_variable) @variable
(objectscript_identifier) @variable

(method_arg) @variable.parameter
; I didn't include ( or ) in this, because they are often grouped
; as part of a sequence that gets turned into a single token, so they
; don't get matched, and one ends up getting colored differently than the other.
[
"_"
","
":"
"."
".."
"..."
"'["
"']"
"']]"
"\""
"\"\""
"["
"]"
"]]"
"{"
"}"
"/"
"\\"
"#"
"|"
"||"
"/"
"/"
"$$"
] @punctuation

[
"'&"
"&"
"&&"
"'<"
"'="
"'>"
"^"
"-"
"^$"
"+"
"<"
"<="
"="
">"
">="
"@"
"*"
"**"
"'"
"'!"
"'?"
"!"
"?"
] @operator

(json_string_literal) @string
(json_boolean_literal) @boolean
(json_number_literal) @number
(json_null_literal) @string
(bracket) @punctuation.bracket

; CORE GRAMMAR HIGHLIGHTS
(locktype) @variable

(macro_arg) @variable
(macro_value) @constant.builtin
keyword: (_) @keyword

(embedded_js_special_case_complete) @punctuation.special
(embedded_sql_marker) @punctuation.special
(embedded_sql_reverse_marker) @punctuation.special
(html_marker) @punctuation.special
(html_marker_reversed) @punctuation.special

(attribute) @attribute

(open_keywords) @attribute
(use_keywords) @attribute
(close_parameter_option_value) @attribute

[
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
] @comment

(tag) @tag

[
"--"
";"
"//"
"#;"
"##;"
"$"
] @punctuation

; UDL grammar highlights
[
(method_keyword_codemode_expression)
(call_method_keyword)
(method_keyword)
(class_keywords)
(query_keywords)
(trigger_keyword)
(method_keyword_language)
(relationship_keyword)
(foreignkey_keyword)
(parameter_keyword)
(projection_keyword)
(index_keyword)
(index_keyword_extent)
(xdata_keyword)
(xdata_keyword_mimetype)
(property_keyword)

] @attribute

(documatic_line) @comment.doc

(query_name) @property
(property_name) @property
(relationship_name) @property
(foreignkey_name) @property
(parameter_name) @property
(projection_name) @property
(index_name) @property
(xdata_name) @property
(storage_name) @property

(return_type) @type.builtin
(typename) @type
(parameter_type) @type.builtin
(index_type) @type.builtin
(projection_type) @type.builtin
(property_type) @type.builtin
(index_property_type) @type.builtin

(identifier) @variable
5 changes: 5 additions & 0 deletions languages/objectscript/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
("{" @indents.begin)
("}" @indents.end)



192 changes: 192 additions & 0 deletions languages/objectscript/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
; Core grammar injections
(embedded_html
(angled_bracket_fenced_text) @injection.content
(#set! injection.language "html")
)

(embedded_sql
(_
(paren_fenced_text) @injection.content
)
(#set! injection.language "sql")
)

(embedded_js
[
(angled_bracket_fenced_text)
(embedded_js_special_case)
] @injection.content
(#set! injection.language "javascript"))


(embedded_xml
(angled_bracket_fenced_text) @injection.content
(#set! injection.language "xml")
)

([
(line_comment_1)
(line_comment_2)
(line_comment_3)
(block_comment)
] @injection.content
(#set! injection.language "comment"))



; UDL injections
;; Keywords, one of type language = "python", none of type codemode
; External method body injection based on [ Language = ... ]
(method_definition
(external_method_keywords
(method_keyword_language
(rhs) @lang))
(external_method_body_content) @injection.content
(#set! injection.include-children "true")
(#match? @lang "^[Pp][Yy][Tt][Hh][Oo][Nn]$")
(#set! injection.language "python"))

(method_definition
(external_method_keywords
(method_keyword_language
(rhs) @lang))
(external_method_body_content) @injection.content
(#set! injection.include-children "true")
(#match? @lang "^[Tt][Ss][Qq][Ll]$")
(#set! injection.language "tsql"))

(method_definition
(external_method_keywords
(method_keyword_language
(rhs) @lang))
(external_method_body_content) @injection.content
(#set! injection.include-children "true")
(#match? @lang "^[Ii][Ss][Pp][Ll]$")
(#set! injection.language "ispl"))



;; External trigger with python body
(
(trigger
(external_trigger
(trigger_keywords
(method_keyword_language
(rhs) @lang))
(external_method_body_content) @injection.content))
(#set! injection.include-children "true")
(#match? @lang "^[Pp][Yy][Tt][Hh][Oo][Nn]$")
(#set! injection.language "python")
)

;; External trigger with TSQL body
(
(trigger
(external_trigger
(trigger_keywords
(method_keyword_language
(rhs) @lang))
(external_method_body_content) @injection.content))
(#set! injection.include-children "true")
(#match? @lang "^[Tt][Ss][Qq][Ll]$")
(#set! injection.language "tsql")
)

; A query must be of type %SQLQuery to have an SQL body, otherwise the body
; is empty
(query
(return_type
(typename
(identifier) @_querytype
(#match? @_querytype "^%[Ss][Qq][Ll][Qq][Uu][Ee][Rr][Yy]$")))
(query_body
(query_body_content) @injection.content)
(#set! injection.language "sql")
(#set! injection.include-children "true")
)

; XDATA blocks:
; - xdata_any requires a keyword list that includes MimeType
; - xdata_xml allows an optional keyword list and defaults to XML

; ----------------------------
; XDATA injections (MimeType)
; ----------------------------

; text/markdown
(xdata
(xdata_any
(xdata_keywords
(xdata_keyword_mimetype (rhs) @mt))
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#match? @mt "^\"?text/markdown\"?$")
(#set! injection.language "markdown"))

; XML MimeTypes
(xdata
(xdata_any
(xdata_keywords
(xdata_keyword_mimetype (rhs) @mt))
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#match? @mt "^\"?([Tt][Ee][Xx][Tt]|[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn])/[Xx][Mm][Ll]\"?$")
(#set! injection.language "xml"))

; text/html
(xdata
(xdata_any
(xdata_keywords
(xdata_keyword_mimetype (rhs) @mt))
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#match? @mt "^\"?text/html\"?$")
(#set! injection.language "html"))

; application/json
(xdata
(xdata_any
(xdata_keywords
(xdata_keyword_mimetype (rhs) @mt))
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#match? @mt "^\"?application/json\"?$")
(#set! injection.language "json"))

; text/yaml or application/yaml
(xdata
(xdata_any
(xdata_keywords
(xdata_keyword_mimetype (rhs) @mt))
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#match? @mt "^\"?([Tt][Ee][Xx][Tt]|[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn])/[Yy][Aa][Mm][Ll]\"?$")
(#set! injection.language "yaml"))

; text/css
(xdata
(xdata_any
(xdata_keywords
(xdata_keyword_mimetype (rhs) @mt))
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#match? @mt "^\"?text/css\"?$")
(#set! injection.language "css"))

; -----------------------------------------
; XDATA default (no MimeType): XML fallback
; -----------------------------------------
(xdata
(xdata_xml
(xdata_keywords)?
(external_method_body_content) @injection.content)
(#set! injection.include-children "true")
(#set! injection.language "xml"))


; Storage definition is XML
(storage
(storage_body
(external_method_body_content) @injection.content)
(#set! injection.language "xml")
(#set! injection.include-children "true"))
10 changes: 10 additions & 0 deletions languages/objectscript_core/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = "objectscript_core"
grammar = "objectscript_core"
path_suffixes = ["inc", "mac"]
line_comments = ["// ", ";", ";;", "#;"]
autoclose_before = ";:.,=}])>` \n\t\""
brackets = [
{ start = "{", end = "}", close = true, newline = true },
{ start = "[", end = "]", close = true, newline = false },
{ start = "(", end = ")", close = true, newline = false },
]
Loading