Skip to content

Commit 34f087e

Browse files
committed
lsp: Simplify document symbol extraction for structs
1 parent c3b020e commit 34f087e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

tools/lsp/language.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,18 +1253,17 @@ fn get_document_symbols(
12531253
.collect::<Vec<_>>();
12541254

12551255
r.extend(inner_types.iter().filter_map(|c| match c {
1256-
Type::Struct(s) if s.node().is_some() => Some(DocumentSymbol {
1257-
range: util::node_to_lsp_range(
1258-
s.node().unwrap().parent().as_ref()?,
1259-
document_cache.format,
1260-
),
1261-
selection_range: util::node_to_lsp_range(
1262-
&s.node().unwrap().parent()?.child_node(SyntaxKind::DeclaredIdentifier)?,
1263-
document_cache.format,
1264-
),
1265-
name: s.name.slint_name().unwrap().to_string(),
1266-
kind: lsp_types::SymbolKind::STRUCT,
1267-
..ds.clone()
1256+
Type::Struct(s) => s.node().and_then(|node| {
1257+
Some(DocumentSymbol {
1258+
range: util::node_to_lsp_range(node.parent().as_ref()?, document_cache.format),
1259+
selection_range: util::node_to_lsp_range(
1260+
&node.parent()?.child_node(SyntaxKind::DeclaredIdentifier)?,
1261+
document_cache.format,
1262+
),
1263+
name: s.name.slint_name().unwrap().to_string(),
1264+
kind: lsp_types::SymbolKind::STRUCT,
1265+
..ds.clone()
1266+
})
12681267
}),
12691268
Type::Enumeration(enumeration) => enumeration.node.as_ref().map(|node| DocumentSymbol {
12701269
range: util::node_to_lsp_range(node, document_cache.format),

0 commit comments

Comments
 (0)