mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-26 17:57:19 +00:00
Skip redundant path search in resolve_completion_edits
This commit is contained in:
parent
5df0b592c1
commit
ae74cc3b88
9 changed files with 27 additions and 50 deletions
|
|
@ -411,6 +411,11 @@ pub fn path_from_text(text: &str) -> ast::Path {
|
|||
ast_from_text(&format!("fn main() {{ let test: {text}; }}"))
|
||||
}
|
||||
|
||||
// FIXME: should not be pub
|
||||
pub fn path_from_text_with_edition(text: &str, edition: Edition) -> ast::Path {
|
||||
ast_from_text_with_edition(&format!("fn main() {{ let test: {text}; }}"), edition)
|
||||
}
|
||||
|
||||
pub fn use_tree_glob() -> ast::UseTree {
|
||||
ast_from_text("use *;")
|
||||
}
|
||||
|
|
@ -1230,7 +1235,12 @@ pub fn token_tree(
|
|||
|
||||
#[track_caller]
|
||||
fn ast_from_text<N: AstNode>(text: &str) -> N {
|
||||
let parse = SourceFile::parse(text, Edition::CURRENT);
|
||||
ast_from_text_with_edition(text, Edition::CURRENT)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn ast_from_text_with_edition<N: AstNode>(text: &str, edition: Edition) -> N {
|
||||
let parse = SourceFile::parse(text, edition);
|
||||
let node = match parse.tree().syntax().descendants().find_map(N::cast) {
|
||||
Some(it) => it,
|
||||
None => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue