#![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::request::GotoDefinitionResponse;
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 CompletionFuture: Future<Item = Option<CompletionResponse>, Error = Error> + Send;
type HoverFuture: Future<Item = Option<Hover>, Error = Error> + Send;
type DeclarationFuture: Future<Item = Option<GotoDefinitionResponse>, Error = Error> + Send;
type DefinitionFuture: Future<Item = Option<GotoDefinitionResponse>, Error = Error> + Send;
type TypeDefinitionFuture: Future<Item = Option<GotoDefinitionResponse>, Error = Error> + Send;
type HighlightFuture: Future<Item = Option<Vec<DocumentHighlight>>, Error = Error> + Send;
fn initialize(&self, printer: &Printer, 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 completion(&self, params: CompletionParams) -> Self::CompletionFuture;
fn hover(&self, params: TextDocumentPositionParams) -> Self::HoverFuture;
fn goto_declaration(&self, params: TextDocumentPositionParams) -> Self::DeclarationFuture;
fn goto_definition(&self, params: TextDocumentPositionParams) -> Self::DefinitionFuture;
fn goto_type_definition(
&self,
params: TextDocumentPositionParams,
) -> Self::TypeDefinitionFuture;
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 CompletionFuture = S::CompletionFuture;
type HoverFuture = S::HoverFuture;
type DeclarationFuture = S::DeclarationFuture;
type DefinitionFuture = S::DefinitionFuture;
type TypeDefinitionFuture = S::TypeDefinitionFuture;
type HighlightFuture = S::HighlightFuture;
fn initialize(&self, printer: &Printer, params: InitializeParams) -> Result<InitializeResult> {
(**self).initialize(printer, 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 completion(&self, params: CompletionParams) -> Self::CompletionFuture {
(**self).completion(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 goto_declaration(&self, params: TextDocumentPositionParams) -> Self::DeclarationFuture {
(**self).goto_declaration(params)
}
fn goto_definition(&self, params: TextDocumentPositionParams) -> Self::DefinitionFuture {
(**self).goto_definition(params)
}
fn goto_type_definition(
&self,
params: TextDocumentPositionParams,
) -> Self::TypeDefinitionFuture {
(**self).goto_type_definition(params)
}
fn document_highlight(&self, params: TextDocumentPositionParams) -> Self::HighlightFuture {
(**self).document_highlight(params)
}
}