aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-15 16:22:39 +0100
committerLukas Wirth <[email protected]>2021-05-15 16:22:39 +0100
commit3da52d2e936bf797d7fe1a9c6c9fad78e19c7d83 (patch)
treeaf57c9ea7bff5622c240085357f2ec8b5524f763 /crates
parente5e6c363dc7ef081d6c9a5377563d3632c579ab2 (diff)
simplify
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/matching_brace.rs12
-rw-r--r--crates/ide/src/parent_module.rs6
2 files changed, 8 insertions, 10 deletions
diff --git a/crates/ide/src/matching_brace.rs b/crates/ide/src/matching_brace.rs
index 261dcc255..011c8cc55 100644
--- a/crates/ide/src/matching_brace.rs
+++ b/crates/ide/src/matching_brace.rs
@@ -19,14 +19,10 @@ use syntax::{
19pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> { 19pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> {
20 const BRACES: &[SyntaxKind] = 20 const BRACES: &[SyntaxKind] =
21 &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]]; 21 &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]];
22 let (brace_token, brace_idx) = file 22 let (brace_token, brace_idx) = file.syntax().token_at_offset(offset).find_map(|node| {
23 .syntax() 23 let idx = BRACES.iter().position(|&brace| brace == node.kind())?;
24 .token_at_offset(offset) 24 Some((node, idx))
25 .filter_map(|node| { 25 })?;
26 let idx = BRACES.iter().position(|&brace| brace == node.kind())?;
27 Some((node, idx))
28 })
29 .next()?;
30 let parent = brace_token.parent()?; 26 let parent = brace_token.parent()?;
31 if brace_token.kind() == T![|] && !ast::ParamList::can_cast(parent.kind()) { 27 if brace_token.kind() == T![|] && !ast::ParamList::can_cast(parent.kind()) {
32 cov_mark::hit!(pipes_not_braces); 28 cov_mark::hit!(pipes_not_braces);
diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs
index 99365c8a7..9b1f48044 100644
--- a/crates/ide/src/parent_module.rs
+++ b/crates/ide/src/parent_module.rs
@@ -1,6 +1,8 @@
1use hir::Semantics; 1use hir::Semantics;
2use ide_db::base_db::{CrateId, FileId, FilePosition}; 2use ide_db::{
3use ide_db::RootDatabase; 3 base_db::{CrateId, FileId, FilePosition},
4 RootDatabase,
5};
4use itertools::Itertools; 6use itertools::Itertools;
5use syntax::{ 7use syntax::{
6 algo::find_node_at_offset, 8 algo::find_node_at_offset,