diff --git a/extension.toml b/extension.toml index cb96e41..c96dcca 100644 --- a/extension.toml +++ b/extension.toml @@ -8,17 +8,17 @@ repository = "https://github.com/intersystems/zed-objectscript" [grammars.objectscript_udl] repository = "https://github.com/intersystems/tree-sitter-objectscript" -commit = "58432d03bfba25efad3059a52d0916d714739b09" +commit = "e2193fdc37b5c64f3d442873a3d7ed2992c2cecf" path = "udl" [grammars.objectscript_routine] repository = "https://github.com/intersystems/tree-sitter-objectscript" -commit = "58432d03bfba25efad3059a52d0916d714739b09" +commit = "e2193fdc37b5c64f3d442873a3d7ed2992c2cecf" path = "objectscript_routine" [grammars.objectscript] repository = "https://github.com/intersystems/tree-sitter-objectscript" -commit = "58432d03bfba25efad3059a52d0916d714739b09" +commit = "e2193fdc37b5c64f3d442873a3d7ed2992c2cecf" path = "objectscript" [grammars.xml] diff --git a/languages/objectscript/highlights.scm b/languages/objectscript/highlights.scm index 7107b02..fdcdee5 100644 --- a/languages/objectscript/highlights.scm +++ b/languages/objectscript/highlights.scm @@ -20,7 +20,9 @@ [ (keyword_super) (keyword_pound_pound_class) -] @keyword + (keyword_quote_directive) + (keyword_pound_expression) +] @property (system_defined_function) @constant.builtin @@ -78,6 +80,7 @@ (ssvn) (system_defined_variable) "$$" + (keyword_this) ] @variable.special [ @@ -86,7 +89,15 @@ ] @variant (method_arg) @variable.parameter - +[(line_comment_1) +(line_comment_2) +(line_comment_3) +(line_comment_4) +(block_comment) +(inline_comment) +(argumentless_inline_comment) +] @comment +(documatic_line) @comment.doc ; 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. @@ -139,16 +150,15 @@ "?" ] @operator -; === END EXPR === -; === BEGIN CORE === (macro_arg) @variant (macro_value) @constant.builtin -(macro_def) @preproc +(macro_def) @property [ (keyword_pound_define) + (keyword_sqlcompile) (keyword_pound_def1arg) (keyword_pound_if) (keyword_pound_elseif) @@ -162,7 +172,8 @@ (keyword_pound_delay) (locktype) (tag_end_if) -] @preproc + (pound_execute) +] @property [ (keyword_as) @@ -193,6 +204,7 @@ (keyword_ztrap) (keyword_zz) (keyword_print) + (keyword_select) (keyword_zprint) (keyword_set) (keyword_write) @@ -234,6 +246,7 @@ (keyword_throw) (keyword_try) (keyword_catch) + (keyword_zedit) ] @keyword [ @@ -252,6 +265,11 @@ (html_marker_reversed) ] @punctuation.special +[ + (pound_if_special_case_else) + (pound_if_special_case) +] @comment + (tag) @function "--" @operator @@ -284,8 +302,7 @@ "." @constant.builtin) ; === END CORE === -; === BEGIN LOCAL === -(iris_username) @preproc +(iris_username) @property [ (keyword_import) @@ -293,6 +310,7 @@ (keyword_includegenerator) (keyword_method) (keyword_classmethod) + (keyword_clientmethod) (keyword_extends) (keyword_property) (keyword_relationship) @@ -329,7 +347,6 @@ (property_keyword) ] @type.builtin - [ (query_name) (trigger_name) @@ -341,19 +358,14 @@ (xdata_name) (storage_name) (xml_identifier) - (index_property) (column_name) ] @variant [ - (return_type) (keyword_list) - (parameter_type) - (index_type) - (index_property_type) (typename) ] @type.builtin -; === END UDL === + ; routine (routine_type) @type.builtin diff --git a/languages/objectscript/injections.scm b/languages/objectscript/injections.scm index 94c8c91..e30f2e8 100644 --- a/languages/objectscript/injections.scm +++ b/languages/objectscript/injections.scm @@ -27,8 +27,11 @@ ; Keywords, one of type language = "python", none of type codemode ; External method body injection based on [ Language = ... ] (method_definition - (python_method_body_content) @injection.content + (method_keyword_external_language + (typename) @_lang) + (external_method_body_content) @injection.content (#set! injection.include-children "true") + (#any-of? @_lang "python" "Python" "PYTHON") (#set! injection.language "python")) (method_definition @@ -48,8 +51,11 @@ (#set! injection.language "ispl")) (trigger - (python_method_body_content) @injection.content + (method_keyword_external_language + (typename) @_lang) + (external_method_body_content) @injection.content (#set! injection.include-children "true") + (#any-of? @_lang "python" "Python" "PYTHON") (#set! injection.language "python")) (trigger @@ -87,6 +93,14 @@ (#any-of? @_mt "text/markdown" "\"text/markdown\"") (#set! injection.language "markdown")) +(xdata + (xdata_keyword_mimetype + (typename) @_mt) + (external_method_body_content) @injection.content + (#set! injection.include-children "true") + (#any-of? @_mt "text/x-python" "\"text/x-python\"" "application/python" "\"application/python\"") + (#set! injection.language "python")) + (xdata (xdata_keyword_mimetype (typename) @_mt) @@ -141,7 +155,7 @@ (#set! injection.language "xml") (#set! injection.include-children "true")) - ([ +([ (line_comment_1) (line_comment_2) (line_comment_3) @@ -150,7 +164,7 @@ (inline_comment) (argumentless_inline_comment) (documatic_line) - ] @injection.content - (#set! injection.language "comment")) +] @injection.content + (#set! injection.language "comment")) ; === END LOCAL === diff --git a/languages/objectscript_routine/highlights.scm b/languages/objectscript_routine/highlights.scm index bed8b8d..5acb7f6 100644 --- a/languages/objectscript_routine/highlights.scm +++ b/languages/objectscript_routine/highlights.scm @@ -22,7 +22,9 @@ [ (keyword_super) (keyword_pound_pound_class) -] @keyword + (keyword_quote_directive) + (keyword_pound_expression) +] @property (system_defined_function) @constant.builtin @@ -55,7 +57,7 @@ [ (routine_name) (class_name) -] @type +] @enum [ (macro_function) @@ -77,6 +79,7 @@ [ (ssvn) (system_defined_variable) + (keyword_this) "$$" ] @variable.special @@ -86,6 +89,15 @@ ] @variant (method_arg) @variable.parameter +[(line_comment_1) +(line_comment_2) +(line_comment_3) +(line_comment_4) +(block_comment) +(inline_comment) +(argumentless_inline_comment) +] @comment +(documatic_line) @comment.doc ; 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 @@ -145,7 +157,7 @@ (macro_value) @constant.builtin -(macro_def) @preproc +(macro_def) @property [ (keyword_pound_define) @@ -157,12 +169,14 @@ (keyword_pound_ifdef) (keyword_pound_ifndef) (keyword_dim) + (keyword_sqlcompile) (keyword_pound_import) (keyword_pound_include) (keyword_pound_delay) (locktype) + (pound_execute) (tag_end_if) -] @preproc +] @property [ (keyword_as) @@ -195,6 +209,7 @@ (keyword_print) (keyword_zprint) (keyword_set) + (keyword_select) (keyword_write) (keyword_zwrite) (keyword_do) @@ -234,7 +249,8 @@ (keyword_throw) (keyword_try) (keyword_catch) -] @type.builtin + (keyword_zedit) +] @keyword [ (keyword_embedded_html) @@ -258,6 +274,7 @@ ] @comment (tag) @function +(typename) @type.builtin "--" @operator diff --git a/languages/objectscript_udl/highlights.scm b/languages/objectscript_udl/highlights.scm index 0fb74ab..9ec360f 100644 --- a/languages/objectscript_udl/highlights.scm +++ b/languages/objectscript_udl/highlights.scm @@ -20,7 +20,9 @@ [ (keyword_super) (keyword_pound_pound_class) -] @keyword + (keyword_quote_directive) + (keyword_pound_expression) +] @property (system_defined_function) @constant.builtin @@ -78,6 +80,7 @@ (ssvn) (system_defined_variable) "$$" + (keyword_this) ] @variable.special [ @@ -153,10 +156,11 @@ (macro_value) @constant.builtin -(macro_def) @preproc +(macro_def) @property [ (keyword_pound_define) + (keyword_sqlcompile) (keyword_pound_def1arg) (keyword_pound_if) (keyword_pound_elseif) @@ -170,7 +174,8 @@ (keyword_pound_delay) (locktype) (tag_end_if) -] @preproc + (pound_execute) +] @property [ (keyword_as) @@ -201,6 +206,7 @@ (keyword_ztrap) (keyword_zz) (keyword_print) + (keyword_select) (keyword_zprint) (keyword_set) (keyword_write) @@ -242,6 +248,7 @@ (keyword_throw) (keyword_try) (keyword_catch) + (keyword_zedit) ] @keyword [ @@ -298,7 +305,7 @@ ; === END CORE === ; === BEGIN LOCAL === -(iris_username) @preproc +(iris_username) @property (keyword_class) @attribute @@ -308,6 +315,7 @@ (keyword_includegenerator) (keyword_method) (keyword_classmethod) + (keyword_clientmethod) (keyword_extends) (keyword_property) (keyword_relationship) @@ -355,16 +363,11 @@ (xdata_name) (storage_name) (xml_identifier) - (index_property) (column_name) ] @variant [ - (return_type) (keyword_list) - (parameter_type) - (index_type) - (index_property_type) (typename) ] @type.builtin diff --git a/languages/objectscript_udl/injections.scm b/languages/objectscript_udl/injections.scm index 4dc5b18..e30f2e8 100644 --- a/languages/objectscript_udl/injections.scm +++ b/languages/objectscript_udl/injections.scm @@ -27,8 +27,11 @@ ; Keywords, one of type language = "python", none of type codemode ; External method body injection based on [ Language = ... ] (method_definition - (python_method_body_content) @injection.content + (method_keyword_external_language + (typename) @_lang) + (external_method_body_content) @injection.content (#set! injection.include-children "true") + (#any-of? @_lang "python" "Python" "PYTHON") (#set! injection.language "python")) (method_definition @@ -48,8 +51,11 @@ (#set! injection.language "ispl")) (trigger - (python_method_body_content) @injection.content + (method_keyword_external_language + (typename) @_lang) + (external_method_body_content) @injection.content (#set! injection.include-children "true") + (#any-of? @_lang "python" "Python" "PYTHON") (#set! injection.language "python")) (trigger @@ -87,6 +93,14 @@ (#any-of? @_mt "text/markdown" "\"text/markdown\"") (#set! injection.language "markdown")) +(xdata + (xdata_keyword_mimetype + (typename) @_mt) + (external_method_body_content) @injection.content + (#set! injection.include-children "true") + (#any-of? @_mt "text/x-python" "\"text/x-python\"" "application/python" "\"application/python\"") + (#set! injection.language "python")) + (xdata (xdata_keyword_mimetype (typename) @_mt) @@ -141,16 +155,16 @@ (#set! injection.language "xml") (#set! injection.include-children "true")) -; === END LOCAL === - ([ -(line_comment_1) -(line_comment_2) -(line_comment_3) -(line_comment_4) -(block_comment) -(inline_comment) -(argumentless_inline_comment) -(documatic_line) + (line_comment_1) + (line_comment_2) + (line_comment_3) + (line_comment_4) + (block_comment) + (inline_comment) + (argumentless_inline_comment) + (documatic_line) ] @injection.content (#set! injection.language "comment")) + +; === END LOCAL === diff --git a/objectscript-lsp/Cargo.toml b/objectscript-lsp/Cargo.toml index 8bf2118..9857bbc 100644 --- a/objectscript-lsp/Cargo.toml +++ b/objectscript-lsp/Cargo.toml @@ -13,9 +13,9 @@ objectscript-core = { path = "crates/objectscript-core" } tower-lsp = "0.20.0" tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "fs"] } tree-sitter = "0.26.6" -tree-sitter-objectscript = "1.9.16" -tree-sitter-objectscript-routine = "1.9.16" -tree-sitter-objectscript-playground = "1.9.16" +tree-sitter-objectscript = "1.9.18" +tree-sitter-objectscript-routine = "1.9.18" +tree-sitter-objectscript-playground = "1.9.18" tree-sitter-xml = "0.7.0" serde = "1.0.228" serde_json = "1.0.145" diff --git a/objectscript-lsp/README.md b/objectscript-lsp/README.md index 36daade..32b717e 100644 --- a/objectscript-lsp/README.md +++ b/objectscript-lsp/README.md @@ -76,9 +76,9 @@ In this case, the `DependencyGraph` is used to determine all possible paths to t ## Grammar Baseline - `tree-sitter = 0.26.6` -- `tree-sitter-objectscript = 1.9.16` -- `tree-sitter-objectscript-routine = 1.9.16` -- `tree-sitter-objectscript-playground = 1.9.16` +- `tree-sitter-objectscript = 1.9.18` +- `tree-sitter-objectscript-routine = 1.9.18` +- `tree-sitter-objectscript-playground = 1.9.18` - `tree-sitter-xml = 0.7.0` ## Roadmap diff --git a/objectscript-lsp/crates/objectscript-core/Cargo.toml b/objectscript-lsp/crates/objectscript-core/Cargo.toml index 0daa3bc..0fad352 100644 --- a/objectscript-lsp/crates/objectscript-core/Cargo.toml +++ b/objectscript-lsp/crates/objectscript-core/Cargo.toml @@ -18,9 +18,9 @@ required-features = ["update-bench"] tower-lsp = "0.20.0" tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "fs"] } tree-sitter = "0.26.6" -tree-sitter-objectscript = "1.9.16" -tree-sitter-objectscript-routine = "1.9.16" -tree-sitter-objectscript-playground = "1.9.16" +tree-sitter-objectscript = "1.9.18" +tree-sitter-objectscript-routine = "1.9.18" +tree-sitter-objectscript-playground = "1.9.18" tree-sitter-xml = "0.7.0" serde = "1.0.228" serde_json = "1.0.145" diff --git a/objectscript-lsp/crates/objectscript-core/src/method.rs b/objectscript-lsp/crates/objectscript-core/src/method.rs index f08f7e2..8d2e802 100644 --- a/objectscript-lsp/crates/objectscript-core/src/method.rs +++ b/objectscript-lsp/crates/objectscript-core/src/method.rs @@ -632,12 +632,14 @@ impl Method { method_name_node.byte_range(), ) { - unresolved_method_refs.insert(UnresolvedMethodRef { - class: class_name.to_string(), - method: method_name, - offset: None, - method_call_range: matched_node.range(), - }); + if method_name_node.kind() == "string_literal" { + unresolved_method_refs.insert(UnresolvedMethodRef { + class: class_name.to_string(), + method: method_name, + offset: None, + method_call_range: matched_node.range(), + }); + } } } else { if let Some(classname_method_arg) = matched_node.named_child(0) @@ -660,12 +662,14 @@ impl Method { method_name_node.byte_range(), ) { - unresolved_method_refs.insert(UnresolvedMethodRef { - class: classname_var, - method: method_name, - offset: None, - method_call_range: matched_node.range(), - }); + if method_name_node.kind() == "string_literal" { + unresolved_method_refs.insert(UnresolvedMethodRef { + class: classname_var, + method: method_name, + offset: None, + method_call_range: matched_node.range(), + }); + } } } } else if func_name.eq_ignore_ascii_case("$system") { diff --git a/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hk.cls b/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hk.cls index 88c853c..d91d493 100644 --- a/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hk.cls +++ b/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hk.cls @@ -1,4 +1,5 @@ Class hk { + Relationship manyProp As User.hksubclass [ Cardinality = many, Inverse = oneProp ]; ClassMethod print2() [Private] { w 2 } diff --git a/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hksubclass.cls b/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hksubclass.cls index 009c8e4..8682dd4 100644 --- a/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hksubclass.cls +++ b/objectscript-lsp/objectscript-tests/gotodef/relative-method-call/hksubclass.cls @@ -1,6 +1,8 @@ Class hksubclass Extends (hk, %RegisteredObject) { - Property x; + Relationship oneProp As User.hk [ Cardinality = one, Inverse = manyProp, Required ]; + Property x As %Boolean [InitialExpression = 1]; ClassMethod callInheritedMethod() { d ..print2() + if 1 { d } } }