From 14cb96ec0e6be3b99bfe4ea373c058dcbd2a4f79 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 19:54:16 +0200 Subject: Allign RecordPat with RecordExpr --- crates/ra_ide/src/completion/completion_context.rs | 6 +++--- crates/ra_ide/src/extend_selection.rs | 2 +- crates/ra_ide/src/folding_ranges.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 2a5f3c3d2..29955754c 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -265,7 +265,7 @@ impl<'a> CompletionContext<'a> { return; } // FIXME: remove this (V) duplication and make the check more precise - if name_ref.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { + if name_ref.syntax().ancestors().find_map(ast::RecordPatFieldList::cast).is_some() { self.record_pat_syntax = self.sema.find_node_at_offset_with_macros(&original_file, offset); } @@ -283,7 +283,7 @@ impl<'a> CompletionContext<'a> { { self.is_pat_binding_or_const = false; } - if bind_pat.syntax().parent().and_then(ast::RecordFieldPatList::cast).is_some() { + if bind_pat.syntax().parent().and_then(ast::RecordPatFieldList::cast).is_some() { self.is_pat_binding_or_const = false; } if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { @@ -300,7 +300,7 @@ impl<'a> CompletionContext<'a> { return; } // FIXME: remove this (^) duplication and make the check more precise - if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { + if name.syntax().ancestors().find_map(ast::RecordPatFieldList::cast).is_some() { self.record_pat_syntax = self.sema.find_node_at_offset_with_macros(&original_file, offset); } diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index 319fd500d..7230a0ff9 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs @@ -37,7 +37,7 @@ fn try_extend_selection( let string_kinds = [COMMENT, STRING, RAW_STRING, BYTE_STRING, RAW_BYTE_STRING]; let list_kinds = [ - RECORD_FIELD_PAT_LIST, + RECORD_PAT_FIELD_LIST, MATCH_ARM_LIST, RECORD_FIELD_LIST, TUPLE_FIELD_LIST, diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs index 5a6e17936..903c34996 100644 --- a/crates/ra_ide/src/folding_ranges.rs +++ b/crates/ra_ide/src/folding_ranges.rs @@ -86,7 +86,7 @@ fn fold_kind(kind: SyntaxKind) -> Option { USE => Some(FoldKind::Imports), ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), RECORD_FIELD_LIST - | RECORD_FIELD_PAT_LIST + | RECORD_PAT_FIELD_LIST | RECORD_EXPR_FIELD_LIST | ITEM_LIST | EXTERN_ITEM_LIST -- cgit v1.2.3 From 98181087984157e27faba0b969e384f3c62c39d5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 20:09:09 +0200 Subject: Rename BindPat -> IdentPat --- crates/ra_ide/src/completion/completion_context.rs | 2 +- crates/ra_ide/src/completion/patterns.rs | 2 +- crates/ra_ide/src/display/navigation_target.rs | 4 ++-- crates/ra_ide/src/inlay_hints.rs | 14 +++++++++----- crates/ra_ide/src/references.rs | 14 +++++++------- crates/ra_ide/src/syntax_highlighting.rs | 2 +- 6 files changed, 21 insertions(+), 17 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 29955754c..6b03b30bb 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -275,7 +275,7 @@ impl<'a> CompletionContext<'a> { // Otherwise, see if this is a declaration. We can use heuristics to // suggest declaration names, see `CompletionKind::Magic`. if let Some(name) = find_node_at_offset::(&file_with_fake_ident, offset) { - if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) { + if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::IdentPat::cast) { self.is_pat_binding_or_const = true; if bind_pat.at_token().is_some() || bind_pat.ref_token().is_some() diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs index 9e654b373..7c4feff6d 100644 --- a/crates/ra_ide/src/completion/patterns.rs +++ b/crates/ra_ide/src/completion/patterns.rs @@ -44,7 +44,7 @@ fn test_has_block_expr_parent() { } pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool { - element.ancestors().find(|it| it.kind() == BIND_PAT).is_some() + element.ancestors().find(|it| it.kind() == IDENT_PAT).is_some() } #[test] fn test_has_bind_pat_parent() { diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 45fbc86ef..d70e33e72 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -7,7 +7,7 @@ use ra_ide_db::{defs::Definition, RootDatabase}; use ra_syntax::{ ast::{self, DocCommentsOwner, NameOwner}, match_ast, AstNode, SmolStr, - SyntaxKind::{self, BIND_PAT, TYPE_PARAM}, + SyntaxKind::{self, IDENT_PAT, TYPE_PARAM}, TextRange, }; @@ -339,7 +339,7 @@ impl ToNav for hir::Local { NavigationTarget { file_id: full_range.file_id, name, - kind: BIND_PAT, + kind: IDENT_PAT, full_range: full_range.range, focus_range: None, container_name: None, diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 4bbbcd258..1bacead63 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -78,7 +78,7 @@ pub(crate) fn inlay_hints( match node { ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, - ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); }, + ast::IdentPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); }, _ => (), } } @@ -161,7 +161,7 @@ fn get_param_name_hints( Either::Left(self_param) => Some((self_param.to_string(), arg)), Either::Right(pat) => { let param_name = match pat { - ast::Pat::BindPat(it) => it.name()?.to_string(), + ast::Pat::IdentPat(it) => it.name()?.to_string(), it => it.to_string(), }; Some((param_name, arg)) @@ -182,7 +182,7 @@ fn get_bind_pat_hints( acc: &mut Vec, sema: &Semantics, config: &InlayHintsConfig, - pat: ast::BindPat, + pat: ast::IdentPat, ) -> Option<()> { if !config.type_hints { return None; @@ -202,7 +202,7 @@ fn get_bind_pat_hints( Some(()) } -fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type) -> bool { +fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &Type) -> bool { if let Some(Adt::Enum(enum_data)) = pat_ty.as_adt() { let pat_text = bind_pat.to_string(); enum_data @@ -215,7 +215,11 @@ fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type } } -fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type) -> bool { +fn should_not_display_type_hint( + db: &RootDatabase, + bind_pat: &ast::IdentPat, + pat_ty: &Type, +) -> bool { if pat_ty.is_unknown() { return true; } diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 519e4bf1a..cf456630a 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -150,7 +150,7 @@ fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Optio let stmt = find_node_at_offset::(syntax, range.start())?; if stmt.initializer().is_some() { let pat = stmt.pat()?; - if let ast::Pat::BindPat(it) = pat { + if let ast::Pat::IdentPat(it) = pat { if it.mut_token().is_some() { return Some(ReferenceAccess::Write); } @@ -290,7 +290,7 @@ fn main() { ); check_result( refs, - "i BIND_PAT FileId(1) 24..25 Other Write", + "i IDENT_PAT FileId(1) 24..25 Other Write", &[ "FileId(1) 50..51 Other Write", "FileId(1) 54..55 Other Read", @@ -316,7 +316,7 @@ fn bar() { ); check_result( refs, - "spam BIND_PAT FileId(1) 19..23 Other", + "spam IDENT_PAT FileId(1) 19..23 Other", &["FileId(1) 34..38 Other Read", "FileId(1) 41..45 Other Read"], ); } @@ -330,7 +330,7 @@ fn foo(i : u32) -> u32 { } "#, ); - check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); + check_result(refs, "i IDENT_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); } #[test] @@ -342,7 +342,7 @@ fn foo(i<|> : u32) -> u32 { } "#, ); - check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); + check_result(refs, "i IDENT_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); } #[test] @@ -559,7 +559,7 @@ fn foo() { ); check_result( refs, - "i BIND_PAT FileId(1) 23..24 Other Write", + "i IDENT_PAT FileId(1) 23..24 Other Write", &["FileId(1) 34..35 Other Write", "FileId(1) 38..39 Other Read"], ); } @@ -595,7 +595,7 @@ fn foo() { } "#, ); - check_result(refs, "i BIND_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]); + check_result(refs, "i IDENT_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]); } #[test] diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index e3a96f9d5..027fdecd0 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -717,7 +717,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight { CONST => HighlightTag::Constant, STATIC => HighlightTag::Static, VARIANT => HighlightTag::EnumVariant, - BIND_PAT => HighlightTag::Local, + IDENT_PAT => HighlightTag::Local, _ => default, }; -- cgit v1.2.3