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
InvokeProviderhelper to reduce boilerplate
ARCHITECTURAL ROLE:
- Command layer that exposes language features via Tauri IPC (
#[command]) - Delegates to Environmentβs
LanguageFeatureProvidervia DI withRequire()trait - Translates between frontend JSON parameters and Rust DTO types
- Error strings returned directly to frontend for display
COMMAND REFERENCE (Tauri IPC):
MountainProvideHover: Show hover information at cursor positionMountainProvideCodeActions: Get quick fixes and refactorings for a code rangeMountainProvideDocumentHighlights: Find symbol occurrences in documentMountainProvideCompletions: Get code completion suggestions with contextMountainProvideDefinition: Jump to symbol definition locationMountainProvideReferences: Find all references to a symbol
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 APIvs/workbench/services/languageFeatures/common/languageFeaturesService.ts- service layer
vs/workbench/contrib/hover/browser/hover.ts- hover implementationvs/workbench/contrib/completion/browser/completion.ts- completion widgetvs/workbench/contrib/definition/browser/definition.ts- go to definitionvs/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 helperinvoke_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Β§
- Mountain
Provide Code Actions - Provides code actions (quick fixes and refactorings) for a code range
- Mountain
Provide Completions - Provides code completion suggestions
- Mountain
Provide Definition - Provides go-to-definition functionality
- Mountain
Provide Document Highlights - Finds symbol occurrences (document highlights) in a document
- Mountain
Provide Hover - Provides hover information at cursor position
- Mountain
Provide References - Finds all references to a symbol