mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
apply T! macro where it is possible
This commit is contained in:
parent
d77175ce28
commit
993abedd77
38 changed files with 619 additions and 623 deletions
|
@ -1,13 +1,14 @@
|
|||
use ra_syntax::{
|
||||
SourceFile, TextUnit,
|
||||
algo::find_token_at_offset,
|
||||
SyntaxKind::{self, *},
|
||||
SyntaxKind::{self},
|
||||
ast::AstNode,
|
||||
T
|
||||
};
|
||||
|
||||
pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
|
||||
const BRACES: &[SyntaxKind] =
|
||||
&[L_CURLY, R_CURLY, L_BRACK, R_BRACK, L_PAREN, R_PAREN, L_ANGLE, R_ANGLE];
|
||||
&[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>]];
|
||||
let (brace_node, brace_idx) = find_token_at_offset(file.syntax(), offset)
|
||||
.filter_map(|node| {
|
||||
let idx = BRACES.iter().position(|&brace| brace == node.kind())?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue