From 7e5ab9b78c313c3936cb7cb33de89e3c3c41f2bc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 14 Jan 2019 13:55:56 +0300 Subject: switch to lsp-types --- crates/gen_lsp_server/Cargo.toml | 2 +- crates/gen_lsp_server/src/lib.rs | 6 ++--- crates/gen_lsp_server/src/msg.rs | 2 +- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/caps.rs | 2 +- crates/ra_lsp_server/src/conv.rs | 30 +++++++++++------------ crates/ra_lsp_server/src/main_loop.rs | 2 +- crates/ra_lsp_server/src/main_loop/handlers.rs | 2 +- crates/ra_lsp_server/src/req.rs | 4 +-- crates/ra_lsp_server/src/server_world.rs | 2 +- crates/ra_lsp_server/tests/heavy_tests/main.rs | 2 +- crates/ra_lsp_server/tests/heavy_tests/support.rs | 2 +- 12 files changed, 29 insertions(+), 29 deletions(-) (limited to 'crates') diff --git a/crates/gen_lsp_server/Cargo.toml b/crates/gen_lsp_server/Cargo.toml index a421a3e0b..041151741 100644 --- a/crates/gen_lsp_server/Cargo.toml +++ b/crates/gen_lsp_server/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "Generic LSP server scaffold." [dependencies] -languageserver-types = "0.53.1" +lsp-types = "0.54.0" log = "0.4.3" failure = "0.1.4" serde_json = "1.0.34" diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs index 16ac799ac..edbdda6c8 100644 --- a/crates/gen_lsp_server/src/lib.rs +++ b/crates/gen_lsp_server/src/lib.rs @@ -6,12 +6,12 @@ //! //! ```no_run //! extern crate gen_lsp_server; -//! extern crate languageserver_types; +//! extern crate lsp_types; //! extern crate failure; //! extern crate crossbeam_channel; //! //! use crossbeam_channel::{Sender, Receiver}; -//! use languageserver_types::{ServerCapabilities, InitializeParams, request::{GotoDefinition, GotoDefinitionResponse}}; +//! use lsp_types::{ServerCapabilities, InitializeParams, request::{GotoDefinition, GotoDefinitionResponse}}; //! use gen_lsp_server::{run_server, stdio_transport, handle_shutdown, RawMessage, RawResponse}; //! //! fn main() -> Result<(), failure::Error> { @@ -65,7 +65,7 @@ mod msg; mod stdio; use crossbeam_channel::{Receiver, Sender}; -use languageserver_types::{ +use lsp_types::{ notification::{Exit, Initialized}, request::{Initialize, Shutdown}, InitializeParams, InitializeResult, ServerCapabilities, diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs index 94bef374c..818111fe7 100644 --- a/crates/gen_lsp_server/src/msg.rs +++ b/crates/gen_lsp_server/src/msg.rs @@ -1,6 +1,6 @@ use std::io::{BufRead, Write}; -use languageserver_types::{notification::Notification, request::Request}; +use lsp_types::{notification::Notification, request::Request}; use serde::{Deserialize, Serialize}; use serde_json::{from_str, from_value, to_string, to_value, Value}; use failure::{bail, format_err}; diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 7e307eb1c..0557897fd 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -17,7 +17,7 @@ crossbeam-channel = "0.3.5" flexi_logger = "0.10.0" log = "0.4.3" url_serde = "0.2.0" -languageserver-types = "0.53.1" +lsp-types = "0.54.0" walkdir = "2.2.7" im = "12.0.0" cargo_metadata = "0.6.0" diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index be6a6ead6..bca079d65 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -1,4 +1,4 @@ -use languageserver_types::{ +use lsp_types::{ CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 687663d8a..6e187d49e 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -1,4 +1,4 @@ -use languageserver_types::{ +use lsp_types::{ self, CreateFile, DocumentChangeOperation, DocumentChanges, InsertTextFormat, Location, LocationLink, Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, @@ -51,10 +51,10 @@ impl Conv for SyntaxKind { } impl Conv for CompletionItemKind { - type Output = ::languageserver_types::CompletionItemKind; + type Output = ::lsp_types::CompletionItemKind; fn conv(self) -> ::Output { - use languageserver_types::CompletionItemKind::*; + use lsp_types::CompletionItemKind::*; match self { CompletionItemKind::Keyword => Keyword, CompletionItemKind::Snippet => Snippet, @@ -75,10 +75,10 @@ impl Conv for CompletionItemKind { } impl Conv for CompletionItem { - type Output = ::languageserver_types::CompletionItem; + type Output = ::lsp_types::CompletionItem; fn conv(self) -> ::Output { - let mut res = ::languageserver_types::CompletionItem { + let mut res = ::lsp_types::CompletionItem { label: self.label().to_string(), detail: self.detail().map(|it| it.to_string()), filter_text: Some(self.lookup().to_string()), @@ -148,9 +148,9 @@ impl ConvWith for Range { impl ConvWith for TextEdit { type Ctx = LineIndex; - type Output = Vec; + type Output = Vec; - fn conv_with(self, line_index: &LineIndex) -> Vec { + fn conv_with(self, line_index: &LineIndex) -> Vec { self.as_atoms() .into_iter() .map_conv_with(line_index) @@ -160,10 +160,10 @@ impl ConvWith for TextEdit { impl<'a> ConvWith for &'a AtomTextEdit { type Ctx = LineIndex; - type Output = languageserver_types::TextEdit; + type Output = lsp_types::TextEdit; - fn conv_with(self, line_index: &LineIndex) -> languageserver_types::TextEdit { - languageserver_types::TextEdit { + fn conv_with(self, line_index: &LineIndex) -> lsp_types::TextEdit { + lsp_types::TextEdit { range: self.delete.conv_with(line_index), new_text: self.insert.clone(), } @@ -324,7 +324,7 @@ impl TryConvWith for FileSystemEdit { fn try_conv_with(self, world: &ServerWorld) -> Result { let res = match self { FileSystemEdit::CreateFile { source_root, path } => { - let uri = world.path_to_uri(source_root, &path)?.to_string(); + let uri = world.path_to_uri(source_root, &path)?; ResourceOp::Create(CreateFile { uri, options: None }) } FileSystemEdit::MoveFile { @@ -332,8 +332,8 @@ impl TryConvWith for FileSystemEdit { dst_source_root, dst_path, } => { - let old_uri = world.file_id_to_uri(src)?.to_string(); - let new_uri = world.path_to_uri(dst_source_root, &dst_path)?.to_string(); + let old_uri = world.file_id_to_uri(src)?; + let new_uri = world.path_to_uri(dst_source_root, &dst_path)?; ResourceOp::Rename(RenameFile { old_uri, new_uri, @@ -361,7 +361,7 @@ pub fn to_location_link( // line index for original range file line_index: &LineIndex, ) -> Result { - let url = target.info.file_id().try_conv_with(world)?; + let target_uri = target.info.file_id().try_conv_with(world)?; let tgt_line_index = world.analysis().file_line_index(target.info.file_id()); let target_range = target.info.full_range().conv_with(&tgt_line_index); @@ -374,7 +374,7 @@ pub fn to_location_link( let res = LocationLink { origin_selection_range: Some(target.range.conv_with(line_index)), - target_uri: url.to_string(), + target_uri, target_range, target_selection_range: Some(target_selection_range), }; diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 03c834dbc..19fd294e0 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -9,7 +9,7 @@ use failure_derive::Fail; use gen_lsp_server::{ handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, }; -use languageserver_types::NumberOrString; +use lsp_types::NumberOrString; use ra_ide_api::{Canceled, FileId, LibraryData}; use ra_vfs::VfsTask; use rayon; diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 7326a727d..11a705200 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use gen_lsp_server::ErrorCode; -use languageserver_types::{ +use lsp_types::{ CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, DocumentFormattingParams, DocumentHighlight, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index c2b16725b..156cf9641 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -1,9 +1,9 @@ -use languageserver_types::{Location, Position, Range, TextDocumentIdentifier, Url}; +use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use url_serde; -pub use languageserver_types::{ +pub use lsp_types::{ notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams, CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index d5dbf999f..c24ded9f9 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs @@ -3,7 +3,7 @@ use std::{ sync::Arc, }; -use languageserver_types::Url; +use lsp_types::Url; use ra_ide_api::{ Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 02d62a259..8b5c43a09 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -5,7 +5,7 @@ use std::{ time::Instant, }; -use languageserver_types::{ +use lsp_types::{ CodeActionContext, DocumentFormattingParams, FormattingOptions, Position, Range, }; use ra_lsp_server::req::{ diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 46107b6b6..57a8b4f4d 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -9,7 +9,7 @@ use std::{ use crossbeam_channel::{after, select, Receiver}; use flexi_logger::Logger; use gen_lsp_server::{RawMessage, RawNotification, RawRequest}; -use languageserver_types::{ +use lsp_types::{ notification::DidOpenTextDocument, request::{Request, Shutdown}, DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url, -- cgit v1.2.3