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/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 +- 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'crates/ra_lsp_server/src') 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 -- cgit v1.2.3