Module LanguageFeature

Module LanguageFeature 

Source
Expand description

Β§LanguageFeature (Command)

RESPONSIBILITIES:

  • Defines Tauri command handlers for language feature requests from Sky frontend
  • Bridges Monaco Editor language requests to LanguageFeatureProviderRegistry
  • Provides type-safe parameter handling and validation for LSP features
  • Implements hover, code actions, document highlights, completions, definition, references
  • Uses generic InvokeProvider helper to reduce boilerplate

ARCHITECTURAL ROLE:

  • Command layer that exposes language features via Tauri IPC (#[command])
  • Delegates to Environment’s LanguageFeatureProvider via DI with Require() trait
  • Translates between frontend JSON parameters and Rust DTO types
  • Error strings returned directly to frontend for display

COMMAND REFERENCE (Tauri IPC):

ERROR HANDLING:

  • Returns Result<Value, String> where errors sent directly to frontend
  • Validates URI non-empty and position format (line/character numbers)
  • JSON serialization errors converted to strings
  • Provider errors (CommonError) converted to strings via map_err(|Error| Error.to_string())

PERFORMANCE:

  • Each command is async and non-blocking
  • Provider lookup is O(1) via Require() from DI container
  • URI parsing and DTO deserialization adds minimal overhead

VS CODE REFERENCE:

  • vs/workbench/api/common/extHostLanguageFeatures.ts - ext host language features API
  • vs/workbench/services/languageFeatures/common/languageFeaturesService.ts
    • service layer
  • vs/workbench/contrib/hover/browser/hover.ts - hover implementation
  • vs/workbench/contrib/completion/browser/completion.ts - completion widget
  • vs/workbench/contrib/definition/browser/definition.ts - go to definition
  • vs/workbench/contrib/references/browser/references.ts - find references

TODO:

  • Implement more language features: document symbols, formatting, rename, signature help
  • Add cancellation token support for long-running operations
  • Implement request deduplication for identical concurrent requests
  • Add request caching for repeated symbol lookups
  • Support workspace symbol search
  • Add semantic tokens for syntax highlighting
  • Implement code lens provider
  • Add inlay hints support
  • Support linked editing range
  • Add call hierarchy and type hierarchy
  • Implement document color and color presentation
  • Add folding range provider
  • Support selection range provider

MODULE STRUCTURE:

  • validation.rs - request validation helper
  • invoke_provider.rs - generic provider invoker
  • Individual command modules for each language feature (containing impls only)

ModulesΒ§

code_actions πŸ”’
LanguageFeature - Code Actions
completions πŸ”’
LanguageFeature - Completions
definition πŸ”’
LanguageFeature - Definition
highlights πŸ”’
LanguageFeature - Document Highlights
hover πŸ”’
LanguageFeature - Hover
invoke_provider πŸ”’
LanguageFeature - Invoke Provider Helper
references πŸ”’
LanguageFeature - References
validation πŸ”’
LanguageFeature - Validation

FunctionsΒ§

MountainProvideCodeActions
Provides code actions (quick fixes and refactorings) for a code range
MountainProvideCompletions
Provides code completion suggestions
MountainProvideDefinition
Provides go-to-definition functionality
MountainProvideDocumentHighlights
Finds symbol occurrences (document highlights) in a document
MountainProvideHover
Provides hover information at cursor position
MountainProvideReferences
Finds all references to a symbol