Translator

Struct Translator 

Source
pub struct Translator { /* private fields */ }
Expand description

Translator handles MCP tool calls by converting them to LSP requests.

Implementations§

Source§

impl Translator

Source

pub fn new() -> Self

Create a new translator.

Source

pub fn set_workspace_roots(&mut self, roots: Vec<PathBuf>)

Set the workspace roots for path validation.

Source

pub fn register_client(&mut self, language_id: String, client: LspClient)

Register an LSP client for a language.

Source

pub fn register_server(&mut self, language_id: String, server: LspServer)

Register an LSP server for a language.

Source

pub const fn document_tracker(&self) -> &DocumentTracker

Get the document tracker.

Source

pub const fn document_tracker_mut(&mut self) -> &mut DocumentTracker

Get a mutable reference to the document tracker.

Source

pub const fn notification_cache(&self) -> &NotificationCache

Get the notification cache.

Source

pub const fn notification_cache_mut(&mut self) -> &mut NotificationCache

Get a mutable reference to the notification cache.

Source§

impl Translator

Source

pub async fn handle_hover( &mut self, file_path: String, line: u32, character: u32, ) -> Result<HoverResult>

Handle hover request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_definition( &mut self, file_path: String, line: u32, character: u32, ) -> Result<DefinitionResult>

Handle definition request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_references( &mut self, file_path: String, line: u32, character: u32, include_declaration: bool, ) -> Result<ReferencesResult>

Handle references request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_diagnostics( &mut self, file_path: String, ) -> Result<DiagnosticsResult>

Handle diagnostics request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_rename( &mut self, file_path: String, line: u32, character: u32, new_name: String, ) -> Result<RenameResult>

Handle rename request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_completions( &mut self, file_path: String, line: u32, character: u32, trigger: Option<String>, ) -> Result<CompletionsResult>

Handle completions request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_document_symbols( &mut self, file_path: String, ) -> Result<DocumentSymbolsResult>

Handle document symbols request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_format_document( &mut self, file_path: String, tab_size: u32, insert_spaces: bool, ) -> Result<FormatDocumentResult>

Handle format document request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_workspace_symbol( &mut self, query: String, kind_filter: Option<String>, limit: u32, ) -> Result<WorkspaceSymbolResult>

Handle workspace symbol search.

§Errors

Returns an error if the LSP request fails or no server is configured.

Source

pub async fn handle_code_actions( &mut self, file_path: String, start_line: u32, start_character: u32, end_line: u32, end_character: u32, kind_filter: Option<String>, ) -> Result<CodeActionsResult>

Handle code actions request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_call_hierarchy_prepare( &mut self, file_path: String, line: u32, character: u32, ) -> Result<CallHierarchyPrepareResult>

Handle call hierarchy prepare request.

§Errors

Returns an error if the LSP request fails or the file cannot be opened.

Source

pub async fn handle_incoming_calls( &mut self, item: Value, ) -> Result<IncomingCallsResult>

Handle incoming calls request.

§Errors

Returns an error if the LSP request fails or the item is invalid.

Source

pub async fn handle_outgoing_calls( &mut self, item: Value, ) -> Result<OutgoingCallsResult>

Handle outgoing calls request.

§Errors

Returns an error if the LSP request fails or the item is invalid.

Source

pub fn handle_cached_diagnostics( &mut self, file_path: &str, ) -> Result<DiagnosticsResult>

Handle cached diagnostics request.

§Errors

Returns an error if the path is invalid or outside workspace boundaries.

Source

pub fn handle_server_logs( &mut self, limit: usize, min_level: Option<String>, ) -> Result<ServerLogsResult>

Handle server logs request.

§Errors

Returns an error if the min_level parameter is invalid.

Source

pub fn handle_server_messages( &mut self, limit: usize, ) -> Result<ServerMessagesResult>

Handle server messages request.

§Errors

This method does not return errors.

Trait Implementations§

Source§

impl Debug for Translator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Translator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more