mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
replace make::
to SyntaxFactory::
in inline_type_alias
This commit is contained in:
parent
96f619d0d0
commit
8583e35e4c
@ -9,10 +9,11 @@ use ide_db::{
|
|||||||
search::FileReference,
|
search::FileReference,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use syntax::ast::syntax_factory::SyntaxFactory;
|
||||||
use syntax::syntax_editor::SyntaxEditor;
|
use syntax::syntax_editor::SyntaxEditor;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
AstNode, NodeOrToken, SyntaxNode,
|
AstNode, NodeOrToken, SyntaxNode,
|
||||||
ast::{self, HasGenericParams, HasName, make},
|
ast::{self, HasGenericParams, HasName},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -206,8 +207,8 @@ impl LifetimeMap {
|
|||||||
alias_generics: &ast::GenericParamList,
|
alias_generics: &ast::GenericParamList,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
let mut inner = FxHashMap::default();
|
let mut inner = FxHashMap::default();
|
||||||
|
let make = SyntaxFactory::without_mappings();
|
||||||
let wildcard_lifetime = make::lifetime("'_");
|
let wildcard_lifetime = make.lifetime("'_");
|
||||||
let lifetimes = alias_generics
|
let lifetimes = alias_generics
|
||||||
.lifetime_params()
|
.lifetime_params()
|
||||||
.filter_map(|lp| lp.lifetime())
|
.filter_map(|lp| lp.lifetime())
|
||||||
@ -334,9 +335,10 @@ fn create_replacement(
|
|||||||
};
|
};
|
||||||
let new_string = replacement_syntax.to_string();
|
let new_string = replacement_syntax.to_string();
|
||||||
let new = if new_string == "_" {
|
let new = if new_string == "_" {
|
||||||
make::wildcard_pat().syntax().clone_for_update()
|
let make = SyntaxFactory::without_mappings();
|
||||||
|
make.wildcard_pat().syntax().clone()
|
||||||
} else {
|
} else {
|
||||||
replacement_syntax.clone_for_update()
|
replacement_syntax.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
replacements.push((syntax.clone(), new));
|
replacements.push((syntax.clone(), new));
|
||||||
@ -385,12 +387,15 @@ impl ConstOrTypeGeneric {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn replacement_value(&self) -> Option<SyntaxNode> {
|
fn replacement_value(&self) -> Option<SyntaxNode> {
|
||||||
Some(match self {
|
Some(
|
||||||
ConstOrTypeGeneric::ConstArg(ca) => ca.expr()?.syntax().clone(),
|
match self {
|
||||||
ConstOrTypeGeneric::TypeArg(ta) => ta.syntax().clone(),
|
ConstOrTypeGeneric::ConstArg(ca) => ca.expr()?.syntax().clone(),
|
||||||
ConstOrTypeGeneric::ConstParam(cp) => cp.default_val()?.syntax().clone(),
|
ConstOrTypeGeneric::TypeArg(ta) => ta.syntax().clone(),
|
||||||
ConstOrTypeGeneric::TypeParam(tp) => tp.default_type()?.syntax().clone(),
|
ConstOrTypeGeneric::ConstParam(cp) => cp.default_val()?.syntax().clone(),
|
||||||
})
|
ConstOrTypeGeneric::TypeParam(tp) => tp.default_type()?.syntax().clone(),
|
||||||
|
}
|
||||||
|
.clone_for_update(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user