aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/caps.rs2
-rw-r--r--crates/ra_lsp_server/src/conv.rs30
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs2
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs2
-rw-r--r--crates/ra_lsp_server/src/project_model/cargo_workspace.rs7
-rw-r--r--crates/ra_lsp_server/src/req.rs4
-rw-r--r--crates/ra_lsp_server/src/server_world.rs2
7 files changed, 26 insertions, 23 deletions
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 @@
1use languageserver_types::{ 1use lsp_types::{
2 CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, 2 CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions,
3 ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability, 3 ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability,
4 ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, 4 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 @@
1use languageserver_types::{ 1use lsp_types::{
2 self, CreateFile, DocumentChangeOperation, DocumentChanges, InsertTextFormat, Location, LocationLink, 2 self, CreateFile, DocumentChangeOperation, DocumentChanges, InsertTextFormat, Location, LocationLink,
3 Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, 3 Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier,
4 TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, 4 TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier,
@@ -51,10 +51,10 @@ impl Conv for SyntaxKind {
51} 51}
52 52
53impl Conv for CompletionItemKind { 53impl Conv for CompletionItemKind {
54 type Output = ::languageserver_types::CompletionItemKind; 54 type Output = ::lsp_types::CompletionItemKind;
55 55
56 fn conv(self) -> <Self as Conv>::Output { 56 fn conv(self) -> <Self as Conv>::Output {
57 use languageserver_types::CompletionItemKind::*; 57 use lsp_types::CompletionItemKind::*;
58 match self { 58 match self {
59 CompletionItemKind::Keyword => Keyword, 59 CompletionItemKind::Keyword => Keyword,
60 CompletionItemKind::Snippet => Snippet, 60 CompletionItemKind::Snippet => Snippet,
@@ -75,10 +75,10 @@ impl Conv for CompletionItemKind {
75} 75}
76 76
77impl Conv for CompletionItem { 77impl Conv for CompletionItem {
78 type Output = ::languageserver_types::CompletionItem; 78 type Output = ::lsp_types::CompletionItem;
79 79
80 fn conv(self) -> <Self as Conv>::Output { 80 fn conv(self) -> <Self as Conv>::Output {
81 let mut res = ::languageserver_types::CompletionItem { 81 let mut res = ::lsp_types::CompletionItem {
82 label: self.label().to_string(), 82 label: self.label().to_string(),
83 detail: self.detail().map(|it| it.to_string()), 83 detail: self.detail().map(|it| it.to_string()),
84 filter_text: Some(self.lookup().to_string()), 84 filter_text: Some(self.lookup().to_string()),
@@ -148,9 +148,9 @@ impl ConvWith for Range {
148 148
149impl ConvWith for TextEdit { 149impl ConvWith for TextEdit {
150 type Ctx = LineIndex; 150 type Ctx = LineIndex;
151 type Output = Vec<languageserver_types::TextEdit>; 151 type Output = Vec<lsp_types::TextEdit>;
152 152
153 fn conv_with(self, line_index: &LineIndex) -> Vec<languageserver_types::TextEdit> { 153 fn conv_with(self, line_index: &LineIndex) -> Vec<lsp_types::TextEdit> {
154 self.as_atoms() 154 self.as_atoms()
155 .into_iter() 155 .into_iter()
156 .map_conv_with(line_index) 156 .map_conv_with(line_index)
@@ -160,10 +160,10 @@ impl ConvWith for TextEdit {
160 160
161impl<'a> ConvWith for &'a AtomTextEdit { 161impl<'a> ConvWith for &'a AtomTextEdit {
162 type Ctx = LineIndex; 162 type Ctx = LineIndex;
163 type Output = languageserver_types::TextEdit; 163 type Output = lsp_types::TextEdit;
164 164
165 fn conv_with(self, line_index: &LineIndex) -> languageserver_types::TextEdit { 165 fn conv_with(self, line_index: &LineIndex) -> lsp_types::TextEdit {
166 languageserver_types::TextEdit { 166 lsp_types::TextEdit {
167 range: self.delete.conv_with(line_index), 167 range: self.delete.conv_with(line_index),
168 new_text: self.insert.clone(), 168 new_text: self.insert.clone(),
169 } 169 }
@@ -324,7 +324,7 @@ impl TryConvWith for FileSystemEdit {
324 fn try_conv_with(self, world: &ServerWorld) -> Result<ResourceOp> { 324 fn try_conv_with(self, world: &ServerWorld) -> Result<ResourceOp> {
325 let res = match self { 325 let res = match self {
326 FileSystemEdit::CreateFile { source_root, path } => { 326 FileSystemEdit::CreateFile { source_root, path } => {
327 let uri = world.path_to_uri(source_root, &path)?.to_string(); 327 let uri = world.path_to_uri(source_root, &path)?;
328 ResourceOp::Create(CreateFile { uri, options: None }) 328 ResourceOp::Create(CreateFile { uri, options: None })
329 } 329 }
330 FileSystemEdit::MoveFile { 330 FileSystemEdit::MoveFile {
@@ -332,8 +332,8 @@ impl TryConvWith for FileSystemEdit {
332 dst_source_root, 332 dst_source_root,
333 dst_path, 333 dst_path,
334 } => { 334 } => {
335 let old_uri = world.file_id_to_uri(src)?.to_string(); 335 let old_uri = world.file_id_to_uri(src)?;
336 let new_uri = world.path_to_uri(dst_source_root, &dst_path)?.to_string(); 336 let new_uri = world.path_to_uri(dst_source_root, &dst_path)?;
337 ResourceOp::Rename(RenameFile { 337 ResourceOp::Rename(RenameFile {
338 old_uri, 338 old_uri,
339 new_uri, 339 new_uri,
@@ -361,7 +361,7 @@ pub fn to_location_link(
361 // line index for original range file 361 // line index for original range file
362 line_index: &LineIndex, 362 line_index: &LineIndex,
363) -> Result<LocationLink> { 363) -> Result<LocationLink> {
364 let url = target.info.file_id().try_conv_with(world)?; 364 let target_uri = target.info.file_id().try_conv_with(world)?;
365 let tgt_line_index = world.analysis().file_line_index(target.info.file_id()); 365 let tgt_line_index = world.analysis().file_line_index(target.info.file_id());
366 366
367 let target_range = target.info.full_range().conv_with(&tgt_line_index); 367 let target_range = target.info.full_range().conv_with(&tgt_line_index);
@@ -374,7 +374,7 @@ pub fn to_location_link(
374 374
375 let res = LocationLink { 375 let res = LocationLink {
376 origin_selection_range: Some(target.range.conv_with(line_index)), 376 origin_selection_range: Some(target.range.conv_with(line_index)),
377 target_uri: url.to_string(), 377 target_uri,
378 target_range, 378 target_range,
379 target_selection_range: Some(target_selection_range), 379 target_selection_range: Some(target_selection_range),
380 }; 380 };
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;
9use gen_lsp_server::{ 9use gen_lsp_server::{
10 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, 10 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse,
11}; 11};
12use languageserver_types::NumberOrString; 12use lsp_types::NumberOrString;
13use ra_ide_api::{Canceled, FileId, LibraryData}; 13use ra_ide_api::{Canceled, FileId, LibraryData};
14use ra_vfs::VfsTask; 14use ra_vfs::VfsTask;
15use rayon; 15use 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 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2 2
3use gen_lsp_server::ErrorCode; 3use gen_lsp_server::ErrorCode;
4use languageserver_types::{ 4use lsp_types::{
5 CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, 5 CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity,
6 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, Documentation, FoldingRange, 6 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, Documentation, FoldingRange,
7 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, 7 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent,
diff --git a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs
index 8f7518860..75ae78bca 100644
--- a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs
+++ b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs
@@ -1,6 +1,6 @@
1use std::path::{Path, PathBuf}; 1use std::path::{Path, PathBuf};
2 2
3use cargo_metadata::{metadata_run, CargoOpt}; 3use cargo_metadata::{MetadataCommand, CargoOpt};
4use ra_syntax::SmolStr; 4use ra_syntax::SmolStr;
5use ra_arena::{Arena, RawId, impl_arena_id}; 5use ra_arena::{Arena, RawId, impl_arena_id};
6use rustc_hash::FxHashMap; 6use rustc_hash::FxHashMap;
@@ -117,7 +117,10 @@ impl Target {
117 117
118impl CargoWorkspace { 118impl CargoWorkspace {
119 pub fn from_cargo_metadata(cargo_toml: &Path) -> Result<CargoWorkspace> { 119 pub fn from_cargo_metadata(cargo_toml: &Path) -> Result<CargoWorkspace> {
120 let meta = metadata_run(Some(cargo_toml), true, Some(CargoOpt::AllFeatures)) 120 let meta = MetadataCommand::new()
121 .manifest_path(cargo_toml)
122 .features(CargoOpt::AllFeatures)
123 .exec()
121 .map_err(|e| format_err!("cargo metadata failed: {}", e))?; 124 .map_err(|e| format_err!("cargo metadata failed: {}", e))?;
122 let mut pkg_by_id = FxHashMap::default(); 125 let mut pkg_by_id = FxHashMap::default();
123 let mut packages = Arena::default(); 126 let mut packages = Arena::default();
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 @@
1use languageserver_types::{Location, Position, Range, TextDocumentIdentifier, Url}; 1use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
2use rustc_hash::FxHashMap; 2use rustc_hash::FxHashMap;
3use serde::{Deserialize, Serialize}; 3use serde::{Deserialize, Serialize};
4use url_serde; 4use url_serde;
5 5
6pub use languageserver_types::{ 6pub use lsp_types::{
7 notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams, 7 notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams,
8 CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams, 8 CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams,
9 DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, 9 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::{
3 sync::Arc, 3 sync::Arc,
4}; 4};
5 5
6use languageserver_types::Url; 6use lsp_types::Url;
7use ra_ide_api::{ 7use ra_ide_api::{
8 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, 8 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData,
9 SourceRootId 9 SourceRootId