mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
do refact and fix some issue
This commit is contained in:
parent
1ebfa908d5
commit
adac4fc2f2
7 changed files with 72 additions and 60 deletions
|
@ -13,11 +13,21 @@ use crate::{
|
|||
make::{self, tokens},
|
||||
AstNode, TypeBoundsOwner,
|
||||
},
|
||||
AstToken, Direction, InsertPosition, SmolStr, SyntaxElement,
|
||||
AstToken, Direction, InsertPosition, SmolStr, SyntaxElement, SyntaxKind,
|
||||
SyntaxKind::{ATTR, COMMENT, WHITESPACE},
|
||||
SyntaxNode, SyntaxToken, T,
|
||||
};
|
||||
|
||||
impl ast::BinExpr {
|
||||
#[must_use]
|
||||
pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> {
|
||||
let op_node: SyntaxElement = self.op_details()?.0.into();
|
||||
let to_insert: Option<SyntaxElement> = Some(tokens::op(op).into());
|
||||
let replace_range = RangeInclusive::new(op_node.clone(), op_node);
|
||||
Some(replace_children(self, replace_range, to_insert.into_iter()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::FnDef {
|
||||
#[must_use]
|
||||
pub fn with_body(&self, body: ast::Block) -> ast::FnDef {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue