From 12e3b4c70b5ef23b2fdfc197296d483680e125f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 Feb 2019 14:49:43 +0300 Subject: reformat the world --- crates/ra_lsp_server/src/caps.rs | 20 +++--- crates/ra_lsp_server/src/cargo_target_spec.rs | 5 +- crates/ra_lsp_server/src/conv.rs | 59 ++++------------- crates/ra_lsp_server/src/main.rs | 26 +++----- crates/ra_lsp_server/src/main_loop.rs | 55 ++++------------ crates/ra_lsp_server/src/main_loop/handlers.rs | 75 +++++----------------- .../ra_lsp_server/src/main_loop/subscriptions.rs | 4 +- .../src/project_model/cargo_workspace.rs | 17 ++--- crates/ra_lsp_server/src/project_model/sysroot.rs | 9 +-- crates/ra_lsp_server/src/server_world.rs | 28 ++------ crates/ra_lsp_server/tests/heavy_tests/main.rs | 10 +-- crates/ra_lsp_server/tests/heavy_tests/support.rs | 16 +---- 12 files changed, 77 insertions(+), 247 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index 39992788d..2af2b89fe 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -7,15 +7,13 @@ use lsp_types::{ pub fn server_capabilities() -> ServerCapabilities { ServerCapabilities { - text_document_sync: Some(TextDocumentSyncCapability::Options( - TextDocumentSyncOptions { - open_close: Some(true), - change: Some(TextDocumentSyncKind::Full), - will_save: None, - will_save_wait_until: None, - save: None, - }, - )), + text_document_sync: Some(TextDocumentSyncCapability::Options(TextDocumentSyncOptions { + open_close: Some(true), + change: Some(TextDocumentSyncKind::Full), + will_save: None, + will_save_wait_until: None, + save: None, + })), hover_provider: Some(true), completion_provider: Some(CompletionOptions { resolve_provider: None, @@ -32,9 +30,7 @@ pub fn server_capabilities() -> ServerCapabilities { document_symbol_provider: Some(true), workspace_symbol_provider: Some(true), code_action_provider: Some(CodeActionProviderCapability::Simple(true)), - code_lens_provider: Some(CodeLensOptions { - resolve_provider: Some(true), - }), + code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(true) }), document_formatting_provider: Some(true), document_range_formatting_provider: None, document_on_type_formatting_provider: Some(DocumentOnTypeFormattingOptions { diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index db9496bbe..e011eab7c 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs @@ -64,10 +64,7 @@ impl CargoTargetSpec { None => return Ok(None), }; let file_id = world.analysis().crate_root(crate_id)?; - let path = world - .vfs - .read() - .file2path(ra_vfs::VfsFile(file_id.0.into())); + let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0.into())); let res = world.workspaces.iter().find_map(|ws| { let tgt = ws.cargo.target_by_root(&path)?; let res = CargoTargetSpec { diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 981385466..20077a48a 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -82,11 +82,8 @@ impl ConvWith for CompletionItem { fn conv_with(mut self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { let atom_text_edit = AtomTextEdit::replace(self.source_range(), self.insert_text()); let text_edit = (&atom_text_edit).conv_with(ctx); - let additional_text_edits = if let Some(edit) = self.take_text_edit() { - Some(edit.conv_with(ctx)) - } else { - None - }; + let additional_text_edits = + if let Some(edit) = self.take_text_edit() { Some(edit.conv_with(ctx)) } else { None }; let mut res = lsp_types::CompletionItem { label: self.label().to_string(), @@ -112,10 +109,7 @@ impl ConvWith for Position { type Output = TextUnit; fn conv_with(self, line_index: &LineIndex) -> TextUnit { - let line_col = LineCol { - line: self.line as u32, - col_utf16: self.character as u32, - }; + let line_col = LineCol { line: self.line as u32, col_utf16: self.character as u32 }; line_index.offset(line_col) } } @@ -135,10 +129,7 @@ impl ConvWith for TextRange { type Output = Range; fn conv_with(self, line_index: &LineIndex) -> Range { - Range::new( - self.start().conv_with(line_index), - self.end().conv_with(line_index), - ) + Range::new(self.start().conv_with(line_index), self.end().conv_with(line_index)) } } @@ -147,10 +138,7 @@ impl ConvWith for Range { type Output = TextRange; fn conv_with(self, line_index: &LineIndex) -> TextRange { - TextRange::from_to( - self.start.conv_with(line_index), - self.end.conv_with(line_index), - ) + TextRange::from_to(self.start.conv_with(line_index), self.end.conv_with(line_index)) } } @@ -303,11 +291,7 @@ impl TryConvWith for SourceChange { changes: None, document_changes: Some(DocumentChanges::Operations(document_changes)), }; - Ok(req::SourceChange { - label: self.label, - workspace_edit, - cursor_position, - }) + Ok(req::SourceChange { label: self.label, workspace_edit, cursor_position }) } } @@ -320,16 +304,8 @@ impl TryConvWith for SourceFileEdit { version: None, }; let line_index = world.analysis().file_line_index(self.file_id); - let edits = self - .edit - .as_atoms() - .iter() - .map_conv_with(&line_index) - .collect(); - Ok(TextDocumentEdit { - text_document, - edits, - }) + let edits = self.edit.as_atoms().iter().map_conv_with(&line_index).collect(); + Ok(TextDocumentEdit { text_document, edits }) } } @@ -342,18 +318,10 @@ impl TryConvWith for FileSystemEdit { let uri = world.path_to_uri(source_root, &path)?; ResourceOp::Create(CreateFile { uri, options: None }) } - FileSystemEdit::MoveFile { - src, - dst_source_root, - dst_path, - } => { + FileSystemEdit::MoveFile { src, dst_source_root, dst_path } => { 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, - options: None, - }) + ResourceOp::Rename(RenameFile { old_uri, new_uri, options: None }) } }; Ok(res) @@ -381,11 +349,8 @@ pub fn to_location_link( let target_range = target.info.full_range().conv_with(&tgt_line_index); - let target_selection_range = target - .info - .focus_range() - .map(|it| it.conv_with(&tgt_line_index)) - .unwrap_or(target_range); + let target_selection_range = + target.info.focus_range().map(|it| it.conv_with(&tgt_line_index)).unwrap_or(target_range); let res = LocationLink { origin_selection_range: Some(target.range.conv_with(line_index)), diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 33aa30d70..03f83c7be 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -36,23 +36,15 @@ struct InitializationOptions { fn main_inner() -> Result<()> { let (receiver, sender, threads) = stdio_transport(); let cwd = ::std::env::current_dir()?; - run_server( - ra_lsp_server::server_capabilities(), - receiver, - sender, - |params, r, s| { - let root = params - .root_uri - .and_then(|it| it.to_file_path().ok()) - .unwrap_or(cwd); - let supports_decorations = params - .initialization_options - .and_then(|v| InitializationOptions::deserialize(v).ok()) - .and_then(|it| it.publish_decorations) - == Some(true); - ra_lsp_server::main_loop(false, root, supports_decorations, r, s) - }, - )?; + run_server(ra_lsp_server::server_capabilities(), receiver, sender, |params, r, s| { + let root = params.root_uri.and_then(|it| it.to_file_path().ok()).unwrap_or(cwd); + let supports_decorations = params + .initialization_options + .and_then(|v| InitializationOptions::deserialize(v).ok()) + .and_then(|it| it.publish_decorations) + == Some(true); + ra_lsp_server::main_loop(false, root, supports_decorations, r, s) + })?; log::info!("shutting down IO..."); threads.join()?; log::info!("... IO is down"); diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 26b6fe54a..a51299851 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -25,10 +25,7 @@ use crate::{ }; #[derive(Debug, Fail)] -#[fail( - display = "Language Server request failed with {}. ({})", - code, message -)] +#[fail(display = "Language Server request failed with {}. ({})", code, message)] pub struct LspError { pub code: i32, pub message: String, @@ -69,9 +66,7 @@ pub fn main_loop( } }; ws_worker.shutdown(); - ws_watcher - .shutdown() - .map_err(|_| format_err!("ws watcher died"))?; + ws_watcher.shutdown().map_err(|_| format_err!("ws watcher died"))?; let mut state = ServerWorldState::new(ws_root.clone(), workspaces); log::info!("server initialized, serving requests"); @@ -92,9 +87,7 @@ pub fn main_loop( ); log::info!("waiting for tasks to finish..."); - task_receiver - .into_iter() - .for_each(|task| on_task(task, msg_sender, &mut pending_requests)); + task_receiver.into_iter().for_each(|task| on_task(task, msg_sender, &mut pending_requests)); log::info!("...tasks have finished"); log::info!("joining threadpool..."); drop(pool); @@ -119,9 +112,7 @@ enum Event { impl fmt::Debug for Event { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let debug_verbose_not = |not: &RawNotification, f: &mut fmt::Formatter| { - f.debug_struct("RawNotification") - .field("method", ¬.method) - .finish() + f.debug_struct("RawNotification").field("method", ¬.method).finish() }; match self { @@ -287,13 +278,7 @@ fn on_request( sender: &Sender, req: RawRequest, ) -> Result> { - let mut pool_dispatcher = PoolDispatcher { - req: Some(req), - res: None, - pool, - world, - sender, - }; + let mut pool_dispatcher = PoolDispatcher { req: Some(req), res: None, pool, world, sender }; let req = pool_dispatcher .on::(handlers::handle_analyzer_status)? .on::(handlers::handle_syntax_tree)? @@ -362,13 +347,9 @@ fn on_notification( let not = match not.cast::() { Ok(params) => { let uri = params.text_document.uri; - let path = uri - .to_file_path() - .map_err(|()| format_err!("invalid uri: {}", uri))?; - if let Some(file_id) = state - .vfs - .write() - .add_file_overlay(&path, params.text_document.text) + let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; + if let Some(file_id) = + state.vfs.write().add_file_overlay(&path, params.text_document.text) { subs.add_sub(FileId(file_id.0.into())); } @@ -379,14 +360,9 @@ fn on_notification( let not = match not.cast::() { Ok(mut params) => { let uri = params.text_document.uri; - let path = uri - .to_file_path() - .map_err(|()| format_err!("invalid uri: {}", uri))?; - let text = params - .content_changes - .pop() - .ok_or_else(|| format_err!("empty changes"))? - .text; + let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; + let text = + params.content_changes.pop().ok_or_else(|| format_err!("empty changes"))?.text; state.vfs.write().change_file_overlay(path.as_path(), text); return Ok(()); } @@ -395,16 +371,11 @@ fn on_notification( let not = match not.cast::() { Ok(params) => { let uri = params.text_document.uri; - let path = uri - .to_file_path() - .map_err(|()| format_err!("invalid uri: {}", uri))?; + let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { subs.remove_sub(FileId(file_id.0.into())); } - let params = req::PublishDiagnosticsParams { - uri, - diagnostics: Vec::new(), - }; + let params = req::PublishDiagnosticsParams { uri, diagnostics: Vec::new() }; let not = RawNotification::new::(¶ms); msg_sender.send(RawMessage::Notification(not)).unwrap(); return Ok(()); diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index aa55d1255..0cdb39c32 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -46,12 +46,7 @@ pub fn handle_extend_selection( .into_iter() .map_conv_with(&line_index) .map(|range| FileRange { file_id, range }) - .map(|frange| { - world - .analysis() - .extend_selection(frange) - .map(|it| it.conv_with(&line_index)) - }) + .map(|frange| world.analysis().extend_selection(frange).map(|it| it.conv_with(&line_index))) .collect::>>()?; Ok(req::ExtendSelectionResult { selections }) } @@ -67,10 +62,7 @@ pub fn handle_find_matching_brace( .into_iter() .map_conv_with(&line_index) .map(|offset| { - world - .analysis() - .matching_brace(FilePosition { file_id, offset }) - .unwrap_or(offset) + world.analysis().matching_brace(FilePosition { file_id, offset }).unwrap_or(offset) }) .map_conv_with(&line_index) .collect(); @@ -171,11 +163,7 @@ pub fn handle_workspace_symbol( let all_symbols = params.query.contains('#'); let libs = params.query.contains('*'); let query = { - let query: String = params - .query - .chars() - .filter(|&c| c != '#' && c != '*') - .collect(); + let query: String = params.query.chars().filter(|&c| c != '#' && c != '*').collect(); let mut q = Query::new(query); if !all_symbols { q.only_types(); @@ -367,10 +355,7 @@ pub fn handle_completion( Some(items) => items, }; let line_index = world.analysis().file_line_index(position.file_id); - let items = items - .into_iter() - .map(|item| item.conv_with(&line_index)) - .collect(); + let items = items.into_iter().map(|item| item.conv_with(&line_index)).collect(); Ok(Some(req::CompletionResponse::Array(items))) } @@ -496,9 +481,8 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result return Ok(None), Some(it) => it, @@ -517,14 +501,10 @@ pub fn handle_references( let line_index = world.analysis().file_line_index(file_id); let offset = params.position.conv_with(&line_index); - let refs = world - .analysis() - .find_all_refs(FilePosition { file_id, offset })?; + let refs = world.analysis().find_all_refs(FilePosition { file_id, offset })?; Ok(Some( - refs.into_iter() - .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) - .collect(), + refs.into_iter().filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()).collect(), )) } @@ -540,9 +520,7 @@ pub fn handle_formatting( use std::process; let mut rustfmt = process::Command::new("rustfmt"); - rustfmt - .stdin(process::Stdio::piped()) - .stdout(process::Stdio::piped()); + rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped()); if let Ok(path) = params.text_document.uri.to_file_path() { if let Some(parent) = path.parent() { @@ -582,10 +560,7 @@ pub fn handle_code_action( let line_index = world.analysis().file_line_index(file_id); let range = params.range.conv_with(&line_index); - let assists = world - .analysis() - .assists(FileRange { file_id, range })? - .into_iter(); + let assists = world.analysis().assists(FileRange { file_id, range })?.into_iter(); let fixes = world .analysis() .diagnostics(file_id)? @@ -720,18 +695,11 @@ pub fn handle_code_lens_resolve(world: ServerWorld, code_lens: CodeLens) -> Resu to_value(locations).unwrap(), ]), }; - Ok(CodeLens { - range: code_lens.range, - command: Some(cmd), - data: None, - }) + Ok(CodeLens { range: code_lens.range, command: Some(cmd), data: None }) } None => Ok(CodeLens { range: code_lens.range, - command: Some(Command { - title: "Error".into(), - ..Default::default() - }), + command: Some(Command { title: "Error".into(), ..Default::default() }), data: None, }), } @@ -744,16 +712,11 @@ pub fn handle_document_highlight( let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); - let refs = world - .analysis() - .find_all_refs(params.try_conv_with(&world)?)?; + let refs = world.analysis().find_all_refs(params.try_conv_with(&world)?)?; Ok(Some( refs.into_iter() - .map(|r| DocumentHighlight { - range: r.1.conv_with(&line_index), - kind: None, - }) + .map(|r| DocumentHighlight { range: r.1.conv_with(&line_index), kind: None }) .collect(), )) } @@ -785,10 +748,7 @@ pub fn publish_decorations( file_id: FileId, ) -> Result { let uri = world.file_id_to_uri(file_id)?; - Ok(req::PublishDecorationsParams { - uri, - decorations: highlight(&world, file_id)?, - }) + Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? }) } fn highlight(world: &ServerWorld, file_id: FileId) -> Result> { @@ -797,10 +757,7 @@ fn highlight(world: &ServerWorld, file_id: FileId) -> Result> { .analysis() .highlight(file_id)? .into_iter() - .map(|h| Decoration { - range: h.range.conv_with(&line_index), - tag: h.tag, - }) + .map(|h| Decoration { range: h.range.conv_with(&line_index), tag: h.tag }) .collect(); Ok(res) } diff --git a/crates/ra_lsp_server/src/main_loop/subscriptions.rs b/crates/ra_lsp_server/src/main_loop/subscriptions.rs index a83e01557..11bd952d9 100644 --- a/crates/ra_lsp_server/src/main_loop/subscriptions.rs +++ b/crates/ra_lsp_server/src/main_loop/subscriptions.rs @@ -7,9 +7,7 @@ pub struct Subscriptions { impl Subscriptions { pub fn new() -> Subscriptions { - Subscriptions { - subs: FxHashSet::default(), - } + Subscriptions { subs: FxHashSet::default() } } pub fn add_sub(&mut self, file_id: FileId) { self.subs.insert(file_id); 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 8cf99d586..3b76389d2 100644 --- a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs +++ b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs @@ -118,14 +118,11 @@ impl Target { impl CargoWorkspace { pub fn from_cargo_metadata(cargo_toml: &Path) -> Result { let mut meta = MetadataCommand::new(); - meta.manifest_path(cargo_toml) - .features(CargoOpt::AllFeatures); + meta.manifest_path(cargo_toml).features(CargoOpt::AllFeatures); if let Some(parent) = cargo_toml.parent() { meta.current_dir(parent); } - let meta = meta - .exec() - .map_err(|e| format_err!("cargo metadata failed: {}", e))?; + let meta = meta.exec().map_err(|e| format_err!("cargo metadata failed: {}", e))?; let mut pkg_by_id = FxHashMap::default(); let mut packages = Arena::default(); let mut targets = Arena::default(); @@ -157,10 +154,8 @@ impl CargoWorkspace { for node in resolve.nodes { let source = pkg_by_id[&node.id]; for dep_node in node.deps { - let dep = PackageDependency { - name: dep_node.name.into(), - pkg: pkg_by_id[&dep_node.pkg], - }; + let dep = + PackageDependency { name: dep_node.name.into(), pkg: pkg_by_id[&dep_node.pkg] }; packages[source].dependencies.push(dep); } } @@ -171,8 +166,6 @@ impl CargoWorkspace { self.packages.iter().map(|(id, _pkg)| id) } pub fn target_by_root(&self, root: &Path) -> Option { - self.packages() - .filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)) - .next() + self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() } } diff --git a/crates/ra_lsp_server/src/project_model/sysroot.rs b/crates/ra_lsp_server/src/project_model/sysroot.rs index fb4685671..49210ac7a 100644 --- a/crates/ra_lsp_server/src/project_model/sysroot.rs +++ b/crates/ra_lsp_server/src/project_model/sysroot.rs @@ -53,9 +53,7 @@ impl Sysroot { ); } - let mut sysroot = Sysroot { - crates: Arena::default(), - }; + let mut sysroot = Sysroot { crates: Arena::default() }; for name in SYSROOT_CRATES.trim().lines() { let root = src.join(format!("lib{}", name)).join("lib.rs"); if root.exists() { @@ -77,10 +75,7 @@ impl Sysroot { } fn by_name(&self, name: &str) -> Option { - self.crates - .iter() - .find(|(_id, data)| data.name == name) - .map(|(id, _data)| id) + self.crates.iter().find(|(_id, data)| data.name == name).map(|(id, _data)| id) } } diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index c2167c5d8..02f2a37a8 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs @@ -80,10 +80,7 @@ impl ServerWorldState { } } - let libstd = ws - .sysroot - .std() - .and_then(|it| sysroot_crates.get(&it).map(|&it| it)); + let libstd = ws.sysroot.std().and_then(|it| sysroot_crates.get(&it).map(|&it| it)); let mut pkg_to_lib_crate = FxHashMap::default(); let mut pkg_crates = FxHashMap::default(); @@ -99,10 +96,7 @@ impl ServerWorldState { lib_tgt = Some(crate_id); pkg_to_lib_crate.insert(pkg, crate_id); } - pkg_crates - .entry(pkg) - .or_insert_with(Vec::new) - .push(crate_id); + pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id); } } @@ -192,18 +186,8 @@ impl ServerWorldState { libs.push((SourceRootId(root.0.into()), files)); } } - VfsChange::AddFile { - root, - file, - path, - text, - } => { - change.add_file( - SourceRootId(root.0.into()), - FileId(file.0.into()), - path, - text, - ); + VfsChange::AddFile { root, file, path, text } => { + change.add_file(SourceRootId(root.0.into()), FileId(file.0.into()), path, text); } VfsChange::RemoveFile { root, file, path } => { change.remove_file(SourceRootId(root.0.into()), FileId(file.0.into()), path) @@ -247,9 +231,7 @@ impl ServerWorld { } pub fn uri_to_file_id(&self, uri: &Url) -> Result { - let path = uri - .to_file_path() - .map_err(|()| format_err!("invalid uri: {}", uri))?; + let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; let file = self .vfs .read() diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index bfb0645a8..e49c87169 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -55,10 +55,7 @@ fn foo() { ); server.wait_for_feedback("workspace loaded"); server.request::( - RunnablesParams { - text_document: server.doc_id("lib.rs"), - position: None, - }, + RunnablesParams { text_document: server.doc_id("lib.rs"), position: None }, json!([ { "args": [ "test", "--", "foo", "--nocapture" ], @@ -220,10 +217,7 @@ fn main() {} "#, ); server.wait_for_feedback("workspace loaded"); - let empty_context = || CodeActionContext { - diagnostics: Vec::new(), - only: None, - }; + let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None }; server.request::( CodeActionParams { text_document: server.doc_id("src/lib.rs"), diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 57a8b4f4d..eee85f8c8 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -83,9 +83,7 @@ impl Server { pub fn doc_id(&self, rel_path: &str) -> TextDocumentIdentifier { let path = self.dir.path().join(rel_path); - TextDocumentIdentifier { - uri: Url::from_file_path(path).unwrap(), - } + TextDocumentIdentifier { uri: Url::from_file_path(path).unwrap() } } pub fn request(&self, params: R::Params, expected_resp: Value) @@ -119,11 +117,7 @@ impl Server { } fn send_request_(&self, r: RawRequest) -> Value { let id = r.id; - self.worker - .as_ref() - .unwrap() - .send(RawMessage::Request(r)) - .unwrap(); + self.worker.as_ref().unwrap().send(RawMessage::Request(r)).unwrap(); while let Some(msg) = self.recv() { match msg { RawMessage::Request(req) => panic!("unexpected request: {:?}", req), @@ -169,11 +163,7 @@ impl Server { }) } fn send_notification(&self, not: RawNotification) { - self.worker - .as_ref() - .unwrap() - .send(RawMessage::Notification(not)) - .unwrap(); + self.worker.as_ref().unwrap().send(RawMessage::Notification(not)).unwrap(); } } -- cgit v1.2.3