diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 39eb3df3e..331beab13 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -654,6 +654,29 @@ pub fn handle_code_action( | |||
654 | res.push(action.into()); | 654 | res.push(action.into()); |
655 | } | 655 | } |
656 | 656 | ||
657 | for fix in world.check_watcher.read().fixes_for(¶ms.text_document.uri).into_iter().flatten() | ||
658 | { | ||
659 | let fix_range = fix.location.range.conv_with(&line_index); | ||
660 | if fix_range.intersection(&range).is_none() { | ||
661 | continue; | ||
662 | } | ||
663 | |||
664 | let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())]; | ||
665 | let mut edit_map = std::collections::HashMap::new(); | ||
666 | edit_map.insert(fix.location.uri.clone(), edits); | ||
667 | let edit = WorkspaceEdit::new(edit_map); | ||
668 | |||
669 | let action = CodeAction { | ||
670 | title: fix.title.clone(), | ||
671 | kind: Some("quickfix".to_string()), | ||
672 | diagnostics: Some(fix.diagnostics.clone()), | ||
673 | edit: Some(edit), | ||
674 | command: None, | ||
675 | is_preferred: None, | ||
676 | }; | ||
677 | res.push(action.into()); | ||
678 | } | ||
679 | |||
657 | for assist in assists { | 680 | for assist in assists { |
658 | let title = assist.change.label.clone(); | 681 | let title = assist.change.label.clone(); |
659 | let edit = assist.change.try_conv_with(&world)?; | 682 | let edit = assist.change.try_conv_with(&world)?; |
@@ -820,7 +843,7 @@ pub fn publish_diagnostics( | |||
820 | let _p = profile("publish_diagnostics"); | 843 | let _p = profile("publish_diagnostics"); |
821 | let uri = world.file_id_to_uri(file_id)?; | 844 | let uri = world.file_id_to_uri(file_id)?; |
822 | let line_index = world.analysis().file_line_index(file_id)?; | 845 | let line_index = world.analysis().file_line_index(file_id)?; |
823 | let diagnostics = world | 846 | let mut diagnostics: Vec<Diagnostic> = world |
824 | .analysis() | 847 | .analysis() |
825 | .diagnostics(file_id)? | 848 | .diagnostics(file_id)? |
826 | .into_iter() | 849 | .into_iter() |
@@ -834,6 +857,9 @@ pub fn publish_diagnostics( | |||
834 | tags: None, | 857 | tags: None, |
835 | }) | 858 | }) |
836 | .collect(); | 859 | .collect(); |
860 | if let Some(check_diags) = world.check_watcher.read().diagnostics_for(&uri) { | ||
861 | diagnostics.extend(check_diags.iter().cloned()); | ||
862 | } | ||
837 | Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) | 863 | Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) |
838 | } | 864 | } |
839 | 865 | ||