Skip to content

hkimura-intersys/objectscript-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjectScript LSP

Language Server Protocol implementation for InterSystems ObjectScript using tower-lsp and tree-sitter.

Goal: provide editor-independent ObjectScript semantics for VS Code, Zed, Neovim, and other LSP clients without requiring a live InterSystems server connection.

Current Features

  • Workspace indexing for .cls, .inc, .rtn, .mac, and .int
  • Multi-workspace support through LSP workspace folders, with deepest-parent routing per document
  • Go-to-definition for ObjectScript variables with ProcedureBlock-aware private/public resolution
  • Go-to-implementation for inherited and overridden methods
  • Syntax diagnostics for tracked ObjectScript documents
  • Mixed-language diagnostics for ObjectScript captured from XML Implementation blocks
  • Refactor code actions for:
    • dotted DO rewrites
    • conditional rewrites
    • FOR rewrites
    • document-scoped and workspace-scoped edits
  • Inheritance modeling and override index build
  • Class dependency tracking via objectscript/dependencies:
    • class dependencies (Extends, Import)
    • method-call dependencies (##class, $CLASSMETHOD, $METHOD, filtered self/dot calls)
    • variable dependencies (cross-class public variable refs)
    • oref dependencies (%New()-derived object refs and follow-on calls)
    • SQL dependencies (query, embedded SQL, and SQL Gateway references)

Architecture Summary

  • One ProjectState is created per workspace folder
  • Two-phase semantic build:
    • initial class/routine parse and symbol creation
    • inheritance, variables, call extraction, and dependency tracker rebuild
  • Public symbols live in GlobalSemanticModel
  • Private symbols are tracked through LocalSemanticModel and ScopeTree
  • XML documents are tracked for diagnostics, but they do not enter the class/routine semantic rebuild pipeline
  • Dependency data is stored per class in ClassDependencyTracker

Workspace Layout

  • objectscript-lsp (root crate): LSP transport layer in src/main.rs, src/lsp.rs, and src/server.rs
  • crates/objectscript-core: parsing, semantic model, workspace state, refactors, and dependency tracking
  • crates/objectscript-mcp: MCP server exposing core analysis tools over stdio JSON-RPC
  • objectscript-tests/: fixture corpus for inheritance, dependencies, navigation, and related regressions

LSP Surface

  • Standard requests:
    • textDocument/definition
    • textDocument/implementation
    • textDocument/diagnostic
  • Code actions and execute commands for refactor rewrites
  • Custom request:
    • objectscript/dependencies

For full architecture docs, see:

MCP Tools

Run the MCP server:

cargo run -p objectscript-mcp

Implemented tools:

  • get_objectscript_dependencies
    • Inputs: uri (required), className / class_name (optional), workspaceRoot / workspace_root (optional), refresh (optional)
    • Returns dependency tracker data (class, method, variable, oref, sql) for one class or the whole workspace
  • parse_objectscript_snippet
    • Inputs: code (required), grammar (udl or routine, aliases cls / core), maxNodes (optional)
    • Returns a tree-sitter-backed parse summary for grounded analysis
  • query_objectscript_tree
    • Inputs: query (required), code or uri, grammar (udl or routine, aliases cls / core), maxMatches, maxCapturesPerMatch, includeCaptureText
    • Compiles and runs a tree-sitter query and returns structured matches and captures

Build and Test

cargo build
cargo test

Grammar Baseline

  • tree-sitter = 0.26.6
  • tree-sitter-objectscript = 1.7.13
  • tree-sitter-objectscript-routine = 1.7.13
  • tree-sitter-objectscript-playground = 1.7.13
  • tree-sitter-xml = 0.7.0

Roadmap

  • Semantic diagnostics (undefined variables, unresolved symbols)
  • Broader mixed-language support beyond XML Implementation blocks
  • More lifecycle and incremental edit coverage
  • Expanded semantic support for properties, parameters, queries, triggers, and storage
  • Find references and symbol-oriented LSP features
  • Formatting support beyond the current refactor rewrites

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors