aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api_light/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-08 11:49:43 +0000
committerAleksey Kladov <[email protected]>2019-02-08 11:49:43 +0000
commit12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch)
tree71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_ide_api_light/src/lib.rs
parent5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff)
reformat the world
Diffstat (limited to 'crates/ra_ide_api_light/src/lib.rs')
-rw-r--r--crates/ra_ide_api_light/src/lib.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/crates/ra_ide_api_light/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs
index 17044270c..f3078f51e 100644
--- a/crates/ra_ide_api_light/src/lib.rs
+++ b/crates/ra_ide_api_light/src/lib.rs
@@ -63,9 +63,8 @@ pub struct Diagnostic {
63} 63}
64 64
65pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { 65pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
66 const BRACES: &[SyntaxKind] = &[ 66 const BRACES: &[SyntaxKind] =
67 L_CURLY, R_CURLY, L_BRACK, R_BRACK, L_PAREN, R_PAREN, L_ANGLE, R_ANGLE, 67 &[L_CURLY, R_CURLY, L_BRACK, R_BRACK, L_PAREN, R_PAREN, L_ANGLE, R_ANGLE];
68 ];
69 let (brace_node, brace_idx) = find_leaf_at_offset(file.syntax(), offset) 68 let (brace_node, brace_idx) = find_leaf_at_offset(file.syntax(), offset)
70 .filter_map(|node| { 69 .filter_map(|node| {
71 let idx = BRACES.iter().position(|&brace| brace == node.kind())?; 70 let idx = BRACES.iter().position(|&brace| brace == node.kind())?;
@@ -74,9 +73,7 @@ pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
74 .next()?; 73 .next()?;
75 let parent = brace_node.parent()?; 74 let parent = brace_node.parent()?;
76 let matching_kind = BRACES[brace_idx ^ 1]; 75 let matching_kind = BRACES[brace_idx ^ 1];
77 let matching_node = parent 76 let matching_node = parent.children().find(|node| node.kind() == matching_kind)?;
78 .children()
79 .find(|node| node.kind() == matching_kind)?;
80 Some(matching_node.range().start()) 77 Some(matching_node.range().start())
81} 78}
82 79
@@ -122,10 +119,7 @@ pub fn highlight(root: &SyntaxNode) -> Vec<HighlightedRange> {
122 continue; 119 continue;
123 } 120 }
124 }; 121 };
125 res.push(HighlightedRange { 122 res.push(HighlightedRange { range: node.range(), tag })
126 range: node.range(),
127 tag,
128 })
129 } 123 }
130 res 124 res
131} 125}