#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![forbid(unsafe_code)]
pub extern crate lsp_types;
pub use self::delegate::{MessageStream, Printer};
pub use self::message::Incoming;
pub use self::service::{ExitReceiver, ExitedError, LspService};
pub use self::stdio::Server;
use futures::Future;
use jsonrpc_core::{Error, Result};
use lsp_types::*;
use serde_json::Value;
mod codec;
mod delegate;
mod message;
mod service;
mod stdio;
pub trait LanguageServer: Send + Sync + 'static {
type ShutdownFuture: Future<Item = (), Error = Error> + Send;
type SymbolFuture: Future<Item = Option<Vec<SymbolInformation>>, Error = Error> + Send;
type ExecuteFuture: Future<Item = Option<Value>, Error = Error> + Send;
type HoverFuture: Future<Item = Option<Hover>, Error = Error> + Send;
type HighlightFuture: Future<Item = Option<Vec<DocumentHighlight>>, Error = Error> + Send;
fn initialize(&self, params: InitializeParams) -> Result<InitializeResult>;
fn initialized(&self, printer: &Printer, params: InitializedParams) {
let _ = printer;
let _ = params;
}
fn shutdown(&self) -> Self::ShutdownFuture;
fn did_change_workspace_folders(&self, p: &Printer, params: DidChangeWorkspaceFoldersParams) {
let _ = p;
let _ = params;
}
fn did_change_configuration(&self, printer: &Printer, params: DidChangeConfigurationParams) {
let _ = printer;
let _ = params;
}
fn did_change_watched_files(&self, printer: &Printer, params: DidChangeWatchedFilesParams) {
let _ = printer;
let _ = params;
}
fn symbol(&self, params: WorkspaceSymbolParams) -> Self::SymbolFuture;
fn execute_command(&self, p: &Printer, params: ExecuteCommandParams) -> Self::ExecuteFuture;
fn did_open(&self, printer: &Printer, params: DidOpenTextDocumentParams) {
let _ = printer;
let _ = params;
}
fn did_change(&self, printer: &Printer, params: DidChangeTextDocumentParams) {
let _ = printer;
let _ = params;
}
fn did_save(&self, printer: &Printer, params: DidSaveTextDocumentParams) {
let _ = printer;
let _ = params;
}
fn did_close(&self, printer: &Printer, params: DidCloseTextDocumentParams) {
let _ = printer;
let _ = params;
}
fn hover(&self, params: TextDocumentPositionParams) -> Self::HoverFuture;
fn document_highlight(&self, params: TextDocumentPositionParams) -> Self::HighlightFuture;
}
impl<S: ?Sized + LanguageServer> LanguageServer for Box<S> {
type ShutdownFuture = S::ShutdownFuture;
type SymbolFuture = S::SymbolFuture;
type ExecuteFuture = S::ExecuteFuture;
type HoverFuture = S::HoverFuture;
type HighlightFuture = S::HighlightFuture;
fn initialize(&self, params: InitializeParams) -> Result<InitializeResult> {
(**self).initialize(params)
}
fn initialized(&self, printer: &Printer, params: InitializedParams) {
(**self).initialized(printer, params);
}
fn shutdown(&self) -> Self::ShutdownFuture {
(**self).shutdown()
}
fn did_change_workspace_folders(&self, p: &Printer, params: DidChangeWorkspaceFoldersParams) {
(**self).did_change_workspace_folders(p, params);
}
fn did_change_configuration(&self, printer: &Printer, params: DidChangeConfigurationParams) {
(**self).did_change_configuration(printer, params);
}
fn did_change_watched_files(&self, printer: &Printer, params: DidChangeWatchedFilesParams) {
(**self).did_change_watched_files(printer, params);
}
fn symbol(&self, params: WorkspaceSymbolParams) -> Self::SymbolFuture {
(**self).symbol(params)
}
fn execute_command(&self, p: &Printer, params: ExecuteCommandParams) -> Self::ExecuteFuture {
(**self).execute_command(p, params)
}
fn did_open(&self, printer: &Printer, params: DidOpenTextDocumentParams) {
(**self).did_open(printer, params);
}
fn did_change(&self, printer: &Printer, params: DidChangeTextDocumentParams) {
(**self).did_change(printer, params);
}
fn did_save(&self, printer: &Printer, params: DidSaveTextDocumentParams) {
(**self).did_save(printer, params);
}
fn did_close(&self, printer: &Printer, params: DidCloseTextDocumentParams) {
(**self).did_close(printer, params);
}
fn hover(&self, params: TextDocumentPositionParams) -> Self::HoverFuture {
(**self).hover(params)
}
fn document_highlight(&self, params: TextDocumentPositionParams) -> Self::HighlightFuture {
(**self).document_highlight(params)
}
}