use crate::{connection::{Callback, Endpoint}, Server, TypeProvider};
use self::{did_change_configuration::DidChangeConfigurationOptions, did_change_watched_files::DidChangeWatchedFilesOptions, symbol::SymbolOptions, execute_command::ExecuteCommandOptions, apply_edit::ApplyEdit};
pub mod did_change_configuration;
pub mod did_change_watched_files;
pub mod symbol;
pub mod execute_command;
pub mod apply_edit;
pub(crate) struct WorkspaceService<T: TypeProvider> {
pub(super) did_change_configuration: Endpoint<T, DidChangeConfigurationOptions>,
pub(super) did_change_watched_files: Endpoint<T, DidChangeWatchedFilesOptions>,
pub(super) symbol: Endpoint<T, SymbolOptions>,
pub(super) execute_command: Endpoint<T, ExecuteCommandOptions>,
apply_edit: ApplyEdit<T>
}
impl<T: TypeProvider> WorkspaceService<T> {
pub(super) fn resolve(&self, method: &str) -> Option<Callback<Server<T>>> {
match method {
DidChangeConfigurationOptions::METHOD => Some(self.did_change_configuration.callback()),
SymbolOptions::METHOD => Some(self.symbol.callback()),
ExecuteCommandOptions::METHOD => Some(self.execute_command.callback()),
ApplyEdit::<T>::METHOD => Some(self.apply_edit.callback()),
DidChangeWatchedFilesOptions::METHOD => Some(self.did_change_watched_files.callback()),
_ => None
}
}
}
impl<T: TypeProvider> Default for WorkspaceService<T> {
fn default() -> Self {
WorkspaceService {
did_change_configuration: DidChangeConfigurationOptions::endpoint(),
did_change_watched_files: DidChangeWatchedFilesOptions::endpoint(),
symbol: SymbolOptions::endpoint(),
execute_command: ExecuteCommandOptions::endpoint(),
apply_edit: ApplyEdit::default(),
}
}
}