mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
remove unneeded visited_where_clauses
This commit is contained in:
parent
5778ab1e41
commit
c2cf34db90
1 changed files with 3 additions and 11 deletions
14
crates/ide/src/folding_ranges.rs
Normal file → Executable file
14
crates/ide/src/folding_ranges.rs
Normal file → Executable file
|
@ -36,7 +36,6 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
|
||||||
let mut visited_mods = FxHashSet::default();
|
let mut visited_mods = FxHashSet::default();
|
||||||
let mut visited_consts = FxHashSet::default();
|
let mut visited_consts = FxHashSet::default();
|
||||||
let mut visited_statics = FxHashSet::default();
|
let mut visited_statics = FxHashSet::default();
|
||||||
let mut visited_where_clauses = FxHashSet::default();
|
|
||||||
// regions can be nested, here is a LIFO buffer
|
// regions can be nested, here is a LIFO buffer
|
||||||
let mut regions_starts: Vec<TextSize> = vec![];
|
let mut regions_starts: Vec<TextSize> = vec![];
|
||||||
|
|
||||||
|
@ -113,10 +112,8 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fold where clause
|
// Fold where clause
|
||||||
if node.kind() == WHERE_CLAUSE && !visited_where_clauses.contains(&node) {
|
if node.kind() == WHERE_CLAUSE {
|
||||||
if let Some(range) =
|
if let Some(range) = fold_range_for_where_clause(&node) {
|
||||||
contiguous_range_for_where(&node, &mut visited_where_clauses)
|
|
||||||
{
|
|
||||||
res.push(Fold { range, kind: FoldKind::WhereClause })
|
res.push(Fold { range, kind: FoldKind::WhereClause })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,10 +249,7 @@ fn contiguous_range_for_comment(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contiguous_range_for_where(
|
fn fold_range_for_where_clause(node: &SyntaxNode) -> Option<TextRange> {
|
||||||
node: &SyntaxNode,
|
|
||||||
visited: &mut FxHashSet<SyntaxNode>,
|
|
||||||
) -> Option<TextRange> {
|
|
||||||
let first_where_pred = node.first_child();
|
let first_where_pred = node.first_child();
|
||||||
let last_where_pred = node.last_child();
|
let last_where_pred = node.last_child();
|
||||||
|
|
||||||
|
@ -266,8 +260,6 @@ fn contiguous_range_for_where(
|
||||||
{
|
{
|
||||||
let start = where_kw.text_range().end();
|
let start = where_kw.text_range().end();
|
||||||
let end = last_comma.text_range().end();
|
let end = last_comma.text_range().end();
|
||||||
|
|
||||||
visited.insert(node.clone());
|
|
||||||
return Some(TextRange::new(start, end));
|
return Some(TextRange::new(start, end));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue