Skip to main content

LanguageService

Trait LanguageService 

Source
pub trait LanguageService: Send + Sync {
    type Lang: Language;
    type Vfs: WritableVfs;

Show 31 methods // Required methods fn vfs(&self) -> &Self::Vfs; fn workspace(&self) -> &WorkspaceManager; // Provided methods fn get_source(&self, uri: &str) -> Option<<Self::Vfs as Vfs>::Source> { ... } fn get_root( &self, _uri: &str, ) -> impl Future<Output = Option<RedNode<'_, Self::Lang>>> + Send { ... } fn with_root<'a, R, F>( &'a self, uri: &'a str, f: F, ) -> impl Future<Output = Option<R>> + Send + 'a where R: Send, F: FnOnce(RedNode<'a, Self::Lang>) -> R + Send + 'a { ... } fn with_roots<'a, R, F>( &'a self, uris: Vec<String>, f: F, ) -> impl Future<Output = Vec<R>> + Send + 'a where R: Send + 'static, F: Fn(RedNode<'a, Self::Lang>) -> R + Send + Sync + 'a { ... } fn hover( &self, _uri: &str, _range: Range<usize>, ) -> impl Future<Output = Option<Hover>> + Send { ... } fn folding_ranges( &self, _uri: &str, ) -> impl Future<Output = Vec<FoldingRange>> + Send { ... } fn document_symbols<'a>( &'a self, uri: &'a str, ) -> impl Future<Output = Vec<StructureItem>> + Send + 'a { ... } fn workspace_symbols<'a>( &'a self, query: String, ) -> impl Future<Output = Vec<WorkspaceSymbol>> + Send + 'a { ... } fn list_all_files( &self, root_uri: &str, ) -> impl Future<Output = Vec<String>> + Send { ... } fn definition<'a>( &'a self, uri: &'a str, range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a { ... } fn references<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a { ... } fn type_definition<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a { ... } fn implementation<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a { ... } fn document_highlights<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<DocumentHighlight>> + Send + 'a { ... } fn rename<'a>( &'a self, _uri: &'a str, _range: Range<usize>, _new_name: String, ) -> impl Future<Output = Option<WorkspaceEdit>> + Send + 'a { ... } fn completion<'a>( &'a self, _uri: &'a str, _position: usize, ) -> impl Future<Output = Vec<CompletionItem>> + Send + 'a { ... } fn diagnostics<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Vec<Diagnostic>> + Send + 'a { ... } fn semantic_tokens<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Option<SemanticTokens>> + Send + 'a { ... } fn semantic_tokens_range<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Option<SemanticTokens>> + Send + 'a { ... } fn selection_ranges<'a>( &'a self, _uri: &'a str, _ranges: Vec<usize>, ) -> impl Future<Output = Vec<SelectionRange>> + Send + 'a { ... } fn signature_help<'a>( &'a self, _uri: &'a str, _position: usize, ) -> impl Future<Output = Option<SignatureHelp>> + Send + 'a { ... } fn inlay_hints<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Vec<InlayHint>> + Send + 'a { ... } fn formatting<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Vec<TextEdit>> + Send + 'a { ... } fn code_actions<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<CodeAction>> + Send + 'a { ... } fn initialize<'a>( &'a self, _params: InitializeParams, ) -> impl Future<Output = ()> + Send + 'a { ... } fn initialized<'a>(&'a self) -> impl Future<Output = ()> + Send + 'a { ... } fn shutdown<'a>(&'a self) -> impl Future<Output = ()> + Send + 'a { ... } fn did_save<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = ()> + Send + 'a { ... } fn did_close<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = ()> + Send + 'a { ... }
}

Required Associated Types§

Required Methods§

Source

fn vfs(&self) -> &Self::Vfs

Get the underlying VFS.

Source

fn workspace(&self) -> &WorkspaceManager

Get the workspace manager.

Provided Methods§

Source

fn get_source(&self, uri: &str) -> Option<<Self::Vfs as Vfs>::Source>

Helper to get source from VFS.

Source

fn get_root( &self, _uri: &str, ) -> impl Future<Output = Option<RedNode<'_, Self::Lang>>> + Send

Helper to get the root red node of a file. Implementations should override this to provide actual parsing/caching.

Source

fn with_root<'a, R, F>( &'a self, uri: &'a str, f: F, ) -> impl Future<Output = Option<R>> + Send + 'a
where R: Send, F: FnOnce(RedNode<'a, Self::Lang>) -> R + Send + 'a,

Helper to run logic with the root node.

Source

fn with_roots<'a, R, F>( &'a self, uris: Vec<String>, f: F, ) -> impl Future<Output = Vec<R>> + Send + 'a
where R: Send + 'static, F: Fn(RedNode<'a, Self::Lang>) -> R + Send + Sync + 'a,

Helper to run logic with multiple root nodes in parallel.

Source

fn hover( &self, _uri: &str, _range: Range<usize>, ) -> impl Future<Output = Option<Hover>> + Send

Provide hover information. Defaults to None.

Source

fn folding_ranges( &self, _uri: &str, ) -> impl Future<Output = Vec<FoldingRange>> + Send

Provide folding ranges. Defaults to empty.

Source

fn document_symbols<'a>( &'a self, uri: &'a str, ) -> impl Future<Output = Vec<StructureItem>> + Send + 'a

Provide document symbols. Defaults to empty.

Source

fn workspace_symbols<'a>( &'a self, query: String, ) -> impl Future<Output = Vec<WorkspaceSymbol>> + Send + 'a

Provide workspace symbols.

Source

fn list_all_files( &self, root_uri: &str, ) -> impl Future<Output = Vec<String>> + Send

Helper to list all files recursively.

Source

fn definition<'a>( &'a self, uri: &'a str, range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a

Find definition. Defaults to empty.

Source

fn references<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a

Find references. Defaults to empty.

Source

fn type_definition<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a

Find type definition. Defaults to empty.

Source

fn implementation<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<LocationRange>> + Send + 'a

Find implementation. Defaults to empty.

Source

fn document_highlights<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<DocumentHighlight>> + Send + 'a

Provide document highlights. Defaults to empty.

Source

fn rename<'a>( &'a self, _uri: &'a str, _range: Range<usize>, _new_name: String, ) -> impl Future<Output = Option<WorkspaceEdit>> + Send + 'a

Rename a symbol.

Source

fn completion<'a>( &'a self, _uri: &'a str, _position: usize, ) -> impl Future<Output = Vec<CompletionItem>> + Send + 'a

Provide completion items. Defaults to empty.

Source

fn diagnostics<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Vec<Diagnostic>> + Send + 'a

Provide diagnostics for a file. Defaults to empty.

Source

fn semantic_tokens<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Option<SemanticTokens>> + Send + 'a

Provide semantic tokens for a file. Defaults to None.

Source

fn semantic_tokens_range<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Option<SemanticTokens>> + Send + 'a

Provide semantic tokens for a range. Defaults to None.

Source

fn selection_ranges<'a>( &'a self, _uri: &'a str, _ranges: Vec<usize>, ) -> impl Future<Output = Vec<SelectionRange>> + Send + 'a

Provide selection ranges for a file. Defaults to empty.

Source

fn signature_help<'a>( &'a self, _uri: &'a str, _position: usize, ) -> impl Future<Output = Option<SignatureHelp>> + Send + 'a

Provide signature help at a position. Defaults to None.

Source

fn inlay_hints<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Vec<InlayHint>> + Send + 'a

Provide inlay hints for a file. Defaults to empty.

Source

fn formatting<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = Vec<TextEdit>> + Send + 'a

Provide document formatting. Defaults to empty.

Source

fn code_actions<'a>( &'a self, _uri: &'a str, _range: Range<usize>, ) -> impl Future<Output = Vec<CodeAction>> + Send + 'a

Provide code actions for a file. Defaults to empty.

Source

fn initialize<'a>( &'a self, _params: InitializeParams, ) -> impl Future<Output = ()> + Send + 'a

Called when the language server is initialized.

Source

fn initialized<'a>(&'a self) -> impl Future<Output = ()> + Send + 'a

Called when the language server is initialized (notification).

Source

fn shutdown<'a>(&'a self) -> impl Future<Output = ()> + Send + 'a

Called when the language server is shut down.

Source

fn did_save<'a>(&'a self, _uri: &'a str) -> impl Future<Output = ()> + Send + 'a

Called when a file is saved.

Source

fn did_close<'a>( &'a self, _uri: &'a str, ) -> impl Future<Output = ()> + Send + 'a

Called when a file is closed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§