Fix minor things

This commit is contained in:
Ifeanyi Orizu 2025-08-10 10:02:34 -05:00
parent dc6e6d2b86
commit 0a4d7dcdda
3 changed files with 20 additions and 21 deletions

View file

@ -213,7 +213,6 @@ fn structure_node(node: &SyntaxNode, config: &FileStructureConfig) -> Option<Str
detail: it.ty().map(|ty| ty.to_string()),
deprecated: false,
};
Some(node)
},
ast::ExternBlock(it) => {

View file

@ -3083,7 +3083,7 @@ macro_rules! _config_data {
}) => {
/// Default config values for this grouping.
#[allow(non_snake_case)]
#[derive(Debug, Clone )]
#[derive(Debug, Clone)]
struct $name { $($field: $ty,)* }
impl_for_config_data!{

View file

@ -567,7 +567,7 @@ pub(crate) fn handle_document_symbol(
let file_id = try_default!(from_proto::file_id(&snap, &params.text_document.uri)?);
let line_index = snap.file_line_index(file_id)?;
let mut parents: Vec<(lsp_types::DocumentSymbol, Option<usize>)> = Vec::new();
let mut symbols: Vec<(lsp_types::DocumentSymbol, Option<usize>)> = Vec::new();
let config = snap.config.document_symbol(None);
@ -576,38 +576,38 @@ pub(crate) fn handle_document_symbol(
file_id,
)?;
for symbol in structure_nodes {
for node in structure_nodes {
let mut tags = Vec::new();
if symbol.deprecated {
if node.deprecated {
tags.push(SymbolTag::DEPRECATED)
};
#[allow(deprecated)]
let doc_symbol = lsp_types::DocumentSymbol {
name: symbol.label,
detail: symbol.detail,
kind: to_proto::structure_node_kind(symbol.kind),
let symbol = lsp_types::DocumentSymbol {
name: node.label,
detail: node.detail,
kind: to_proto::structure_node_kind(node.kind),
tags: Some(tags),
deprecated: Some(symbol.deprecated),
range: to_proto::range(&line_index, symbol.node_range),
selection_range: to_proto::range(&line_index, symbol.navigation_range),
deprecated: Some(node.deprecated),
range: to_proto::range(&line_index, node.node_range),
selection_range: to_proto::range(&line_index, node.navigation_range),
children: None,
};
parents.push((doc_symbol, symbol.parent));
symbols.push((symbol, node.parent));
}
// Builds hierarchy from a flat list, in reverse order (so that indices make sense)
// Builds hierarchy from a flat list, in reverse order (so that the indices make sense)
let document_symbols = {
let mut acc = Vec::new();
while let Some((mut node, parent_idx)) = parents.pop() {
if let Some(children) = &mut node.children {
while let Some((mut symbol, parent_idx)) = symbols.pop() {
if let Some(children) = &mut symbol.children {
children.reverse();
}
let parent = match parent_idx {
None => &mut acc,
Some(i) => parents[i].0.children.get_or_insert_with(Vec::new),
Some(i) => symbols[i].0.children.get_or_insert_with(Vec::new),
};
parent.push(node);
parent.push(symbol);
}
acc.reverse();
acc
@ -617,7 +617,7 @@ pub(crate) fn handle_document_symbol(
document_symbols.into()
} else {
let url = to_proto::url(&snap, file_id);
let mut symbol_information = Vec::<SymbolInformation>::new();
let mut symbol_information = Vec::new();
for symbol in document_symbols {
flatten_document_symbol(&symbol, None, &url, &mut symbol_information);
}
@ -654,7 +654,7 @@ pub(crate) fn handle_workspace_symbol(
let _p = tracing::info_span!("handle_workspace_symbol").entered();
let config = snap.config.workspace_symbol(None);
let (all_symbols, libs) = decide_search_scope_and_kind(&params, &config);
let (all_symbols, libs) = decide_search_kind_and_scope(&params, &config);
let query = {
let query: String = params.query.chars().filter(|&c| c != '#' && c != '*').collect();
@ -677,7 +677,7 @@ pub(crate) fn handle_workspace_symbol(
return Ok(Some(lsp_types::WorkspaceSymbolResponse::Nested(res)));
fn decide_search_scope_and_kind(
fn decide_search_kind_and_scope(
params: &WorkspaceSymbolParams,
config: &WorkspaceSymbolConfig,
) -> (bool, bool) {