mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge commit 'a911652360
' into sync-from-ra
This commit is contained in:
parent
0661390ad4
commit
e4866b6ddb
315 changed files with 7088 additions and 4415 deletions
|
@ -53,6 +53,12 @@ fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::Abi {
|
||||
pub fn abi_string(&self) -> Option<ast::String> {
|
||||
support::token(&self.syntax, SyntaxKind::STRING).and_then(ast::String::cast)
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::HasModuleItem for ast::StmtList {}
|
||||
|
||||
impl ast::BlockExpr {
|
||||
|
@ -327,6 +333,14 @@ impl ast::UseTree {
|
|||
pub fn parent_use_tree_list(&self) -> Option<ast::UseTreeList> {
|
||||
self.syntax().parent().and_then(ast::UseTreeList::cast)
|
||||
}
|
||||
|
||||
pub fn top_use_tree(&self) -> ast::UseTree {
|
||||
let mut this = self.clone();
|
||||
while let Some(use_tree_list) = this.parent_use_tree_list() {
|
||||
this = use_tree_list.parent_use_tree();
|
||||
}
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::UseTreeList {
|
||||
|
@ -356,8 +370,12 @@ impl ast::UseTreeList {
|
|||
let remove_brace_in_use_tree_list = |u: &ast::UseTreeList| {
|
||||
let use_tree_count = u.use_trees().count();
|
||||
if use_tree_count == 1 {
|
||||
u.l_curly_token().map(ted::remove);
|
||||
u.r_curly_token().map(ted::remove);
|
||||
if let Some(a) = u.l_curly_token() {
|
||||
ted::remove(a)
|
||||
}
|
||||
if let Some(a) = u.r_curly_token() {
|
||||
ted::remove(a)
|
||||
}
|
||||
u.comma().for_each(ted::remove);
|
||||
}
|
||||
};
|
||||
|
@ -440,6 +458,12 @@ impl ast::Struct {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::Union {
|
||||
pub fn kind(&self) -> StructKind {
|
||||
StructKind::from_node(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::RecordExprField {
|
||||
pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> {
|
||||
let candidate = Self::for_name_ref(field_name)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue