diff options
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 74f73655a..4f77b1b4d 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -272,19 +272,24 @@ pub(crate) fn handle_document_symbol( | |||
272 | parents.push((doc_symbol, symbol.parent)); | 272 | parents.push((doc_symbol, symbol.parent)); |
273 | } | 273 | } |
274 | let mut document_symbols = Vec::new(); | 274 | let mut document_symbols = Vec::new(); |
275 | // Constructs `document_symbols` from `parents`, in order from the end. | ||
275 | while let Some((node, parent)) = parents.pop() { | 276 | while let Some((node, parent)) = parents.pop() { |
276 | match parent { | 277 | match parent { |
277 | None => document_symbols.push(node), | 278 | None => document_symbols.push(node), |
278 | Some(i) => { | 279 | Some(i) => { |
279 | let children = &mut parents[i].0.children; | 280 | parents[i].0.children.get_or_insert_with(Vec::new).push(node); |
280 | if children.is_none() { | ||
281 | *children = Some(Vec::new()); | ||
282 | } | ||
283 | children.as_mut().unwrap().push(node); | ||
284 | } | 281 | } |
285 | } | 282 | } |
286 | } | 283 | } |
287 | 284 | ||
285 | fn reverse(symbols: &mut Vec<DocumentSymbol>) { | ||
286 | for sym in symbols.iter_mut() { | ||
287 | sym.children.as_mut().map(|c| reverse(c)); | ||
288 | } | ||
289 | symbols.reverse(); | ||
290 | } | ||
291 | reverse(&mut document_symbols); | ||
292 | |||
288 | let res = if snap.config.client_caps.hierarchical_symbols { | 293 | let res = if snap.config.client_caps.hierarchical_symbols { |
289 | document_symbols.into() | 294 | document_symbols.into() |
290 | } else { | 295 | } else { |
@@ -770,7 +775,11 @@ fn handle_fixes( | |||
770 | None => {} | 775 | None => {} |
771 | }; | 776 | }; |
772 | 777 | ||
773 | let diagnostics = snap.analysis.diagnostics(file_id, snap.config.experimental_diagnostics)?; | 778 | let diagnostics = snap.analysis.diagnostics( |
779 | file_id, | ||
780 | snap.config.experimental_diagnostics, | ||
781 | snap.config.disabled_diagnostics(), | ||
782 | )?; | ||
774 | 783 | ||
775 | for fix in diagnostics | 784 | for fix in diagnostics |
776 | .into_iter() | 785 | .into_iter() |
@@ -859,10 +868,10 @@ pub(crate) fn handle_resolve_code_action( | |||
859 | .map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect()); | 868 | .map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect()); |
860 | 869 | ||
861 | let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?; | 870 | let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?; |
862 | let (id_string, index) = split_once(¶ms.id, ':').unwrap(); | 871 | let (id, index) = split_once(¶ms.id, ':').unwrap(); |
863 | let index = index.parse::<usize>().unwrap(); | 872 | let index = index.parse::<usize>().unwrap(); |
864 | let assist = &assists[index]; | 873 | let assist = &assists[index]; |
865 | assert!(assist.assist.id().0 == id_string); | 874 | assert!(assist.assist.id.0 == id); |
866 | Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit) | 875 | Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit) |
867 | } | 876 | } |
868 | 877 | ||
@@ -1044,7 +1053,11 @@ pub(crate) fn publish_diagnostics( | |||
1044 | let line_index = snap.analysis.file_line_index(file_id)?; | 1053 | let line_index = snap.analysis.file_line_index(file_id)?; |
1045 | let diagnostics: Vec<Diagnostic> = snap | 1054 | let diagnostics: Vec<Diagnostic> = snap |
1046 | .analysis | 1055 | .analysis |
1047 | .diagnostics(file_id, snap.config.experimental_diagnostics)? | 1056 | .diagnostics( |
1057 | file_id, | ||
1058 | snap.config.experimental_diagnostics, | ||
1059 | snap.config.disabled_diagnostics(), | ||
1060 | )? | ||
1048 | .into_iter() | 1061 | .into_iter() |
1049 | .map(|d| Diagnostic { | 1062 | .map(|d| Diagnostic { |
1050 | range: to_proto::range(&line_index, d.range), | 1063 | range: to_proto::range(&line_index, d.range), |