Skip to content

feat: update to newest tree-sitter-objectscript commit and add language server#9

Merged
davem-intersys merged 4 commits into
intersystems:mainfrom
hkimura-intersys:v1.5.0
Jul 20, 2026
Merged

feat: update to newest tree-sitter-objectscript commit and add language server#9
davem-intersys merged 4 commits into
intersystems:mainfrom
hkimura-intersys:v1.5.0

Conversation

@hkimura-intersys

@hkimura-intersys hkimura-intersys commented Jun 16, 2026

Copy link
Copy Markdown
Member

Moves the objectscript-lsp and objectscript-core crates into this repo and wires the language server into extension.toml.

Extension integration

  • Registered objectscript-lsp in extension.toml for languages objectscript_udl, objectscript_routine, xml, objectscript
  • Added GitHub Actions release workflow (.github/workflows/release.yml) for objectscript-lsp that builds the binary files for the objectscript language server on a tag. This is used in the Zed extension.

Scope tree changes (scope_tree.rs)

  • Conditionals (command_if, else_block, elseif_block) now create child scopes
  • get_scope_for_range added to find which scope a given range belongs to
  • get_scope_children returns all descendant scope IDs

Variable resolution (workspace.rs)

  • Variables now stored as HashMap<String, Vec<(VariableRef, ScopeId)>> — each definition paired with its scope
  • Same-scope resolution: last definition BEFORE the reference wins
  • Child-scope definitions are included in resolution (a set inside an if block is visible in the parent scope)
  • Public variable resolution via dependency graph: if a variable isn't defined locally, traverse callers using all_ancestors to find it

Dependency graph (dependency_tracker.rs)

  • DependencyGraph stores DiGraph<MethodRef, Range> — edge weights are the range of the method call site
  • all_ancestors(target) uses BFS to return callers ordered by proximity (closest first)
  • add_edge(caller, callee, range) creates caller→callee edges

Oref resolution (workspace.rs, lsp.rs) — NEW

  • Added get_oref_definitions — oref goto-definition did not exist before this
  • Resolves method calls on oref instances (e.g. set result = obj.MethodName() navigates to the method definition from the instance tied to that oref)
  • Resolves public variables accessed through orefs via the same dependency graph traversal

Class/method name goto-definition — NEW

  • Goto-definition on a class name reference (e.g. in ##class(ClassName)) navigates to that class definition
  • Goto-definition on a method name reference (e.g. do ..MethodName()) navigates to the method definition
  • Goto-definition on a method name at its own definition navigates to the superclass implementation of that method
  • Goto-definition on a class name at its own definition navigates to the superclass

Dependency graph (dependency_tracker.rs)

  • all_ancestors now returns Vec<(MethodRef, Range, usize)> — includes BFS depth
  • Depth tracking enables "closest ancestor wins" with same-depth peers all returned

Variable building (method.rs)

  • Switched from manual AST parsing to tree-sitter query for set command discovery
  • Query: (command_set (set_argument [(set_target) (set_target_list)] @settarget (expression) @value))
  • This finds ALL set commands recursively, including inside conditionals

Public variable resolution (workspace.rs)

  • Iterates ancestors in BFS order (closest first)
  • When a match is found at depth N, continues collecting at depth N but breaks at depth N+1
  • Multiple ancestors at the same depth all contribute their definitions
  • Same logic applied for oref public variable resolution in find_classes_from_oref

Refactoring label change (refactor.rs)

  • Extracted subroutines now use Private label

@hkimura-intersys hkimura-intersys self-assigned this Jun 16, 2026
@hkimura-intersys
hkimura-intersys marked this pull request as draft July 13, 2026 22:57
This commit moves the objectscript-lsp and objectscript-core
crates into this repo. The lsp crate contains all of the logic
for interacting with the client (IDE), as well as the calls
for goto_definition based on different types of nodes, the
goto_implementation calls, and the diagnostic calls. The core
crate implements all of the logic for building the
underlying structs that are used to represent classes/routines
and their methods/procedures/subroutines and pub/priv variables.
First, conditionals now constitute a new scope.
For two variable definitions in the same scope: The variable definition that comes last
is returned as long as it is still BEFORE the variable reference. (this is for
the scenario that the variable definition is in the same method as the variable reference).

If this is a public variable resolution where the variable is NOT defined in that method/procedure/subroutine,
then the variable definition is looked for in methods that have a call path to the method that
the variable reference was in. For example, if I have methods m1, m2, m3, and m2 calls m1 and m3 calls m2,
and variable x is public in these, then if I am trying to find the variable definition for x in m1, and
it isn't defined in m1, then I would look at m2 and m3 (in order, the first scope that has the variable defined wins)
for the variable definition.
@hkimura-intersys
hkimura-intersys marked this pull request as ready for review July 19, 2026 07:18
@hkimura-intersys hkimura-intersys changed the title feat: update to newest commit and update highlighting to reflect changes feat: update to newest tree-sitter-objectscript commit and add language server Jul 19, 2026
@davem-intersys
davem-intersys merged commit 8e1552e into intersystems:main Jul 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants