mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
move node at offset to aglo already
This commit is contained in:
parent
1b82084a5f
commit
702bdacb03
11 changed files with 19 additions and 22 deletions
|
@ -14,13 +14,11 @@ mod replace_if_let_with_match;
|
|||
use ra_text_edit::{TextEdit, TextEditBuilder};
|
||||
use ra_syntax::{
|
||||
Direction, SyntaxNode, TextUnit, TextRange, SourceFile, AstNode,
|
||||
algo::{find_leaf_at_offset, find_covering_node, LeafAtOffset},
|
||||
algo::{find_leaf_at_offset, find_node_at_offset, find_covering_node, LeafAtOffset},
|
||||
ast::{self, AstToken},
|
||||
};
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::find_node_at_offset;
|
||||
|
||||
pub use self::{
|
||||
flip_comma::flip_comma,
|
||||
add_derive::add_derive,
|
||||
|
|
|
@ -120,10 +120,6 @@ pub fn syntax_tree(file: &SourceFile) -> String {
|
|||
::ra_syntax::utils::dump_tree(file.syntax())
|
||||
}
|
||||
|
||||
pub fn find_node_at_offset<N: AstNode>(syntax: &SyntaxNode, offset: TextUnit) -> Option<&N> {
|
||||
find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ra_syntax::AstNode;
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::mem;
|
|||
|
||||
use itertools::Itertools;
|
||||
use ra_syntax::{
|
||||
algo::{find_covering_node, find_leaf_at_offset, LeafAtOffset},
|
||||
algo::{find_node_at_offset, find_covering_node, find_leaf_at_offset, LeafAtOffset},
|
||||
ast,
|
||||
text_utils::intersect,
|
||||
AstNode, Direction, SourceFile, SyntaxKind,
|
||||
|
@ -11,7 +11,7 @@ use ra_syntax::{
|
|||
};
|
||||
use ra_text_edit::text_utils::contains_offset_nonstrict;
|
||||
|
||||
use crate::{find_node_at_offset, LocalEdit, TextEditBuilder};
|
||||
use crate::{LocalEdit, TextEditBuilder};
|
||||
|
||||
pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit {
|
||||
let range = if range.is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue