mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Reformat all
This commit is contained in:
parent
857c1650ef
commit
6be50f7d5d
35 changed files with 423 additions and 367 deletions
|
@ -174,8 +174,16 @@ mod tests {
|
|||
let file = File::parse(&text);
|
||||
let folds = folding_ranges(&file);
|
||||
|
||||
assert_eq!(folds.len(), ranges.len(), "The amount of folds is different than the expected amount");
|
||||
assert_eq!(folds.len(), fold_kinds.len(), "The amount of fold kinds is different than the expected amount");
|
||||
assert_eq!(
|
||||
folds.len(),
|
||||
ranges.len(),
|
||||
"The amount of folds is different than the expected amount"
|
||||
);
|
||||
assert_eq!(
|
||||
folds.len(),
|
||||
fold_kinds.len(),
|
||||
"The amount of fold kinds is different than the expected amount"
|
||||
);
|
||||
for ((fold, range), fold_kind) in folds
|
||||
.into_iter()
|
||||
.zip(ranges.into_iter())
|
||||
|
|
|
@ -148,8 +148,6 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
|
|||
leaf.ancestors().filter_map(N::cast).next()
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
use crate::TextRange;
|
||||
|
||||
use ra_syntax::{
|
||||
algo::{
|
||||
visit::{visitor, Visitor},
|
||||
},
|
||||
algo::visit::{visitor, Visitor},
|
||||
ast::{self, NameOwner},
|
||||
AstNode, File, SmolStr, SyntaxKind, SyntaxNodeRef,
|
||||
WalkEvent,
|
||||
AstNode, File, SmolStr, SyntaxKind, SyntaxNodeRef, WalkEvent,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -54,7 +51,6 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> {
|
|||
let mut res = Vec::new();
|
||||
let mut stack = Vec::new();
|
||||
|
||||
|
||||
for event in file.syntax().preorder() {
|
||||
match event {
|
||||
WalkEvent::Enter(node) => {
|
||||
|
@ -63,7 +59,7 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> {
|
|||
stack.push(res.len());
|
||||
res.push(symbol);
|
||||
}
|
||||
},
|
||||
}
|
||||
WalkEvent::Leave(node) => {
|
||||
if structure_node(node).is_some() {
|
||||
stack.pop().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue