aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-23 13:55:21 +0100
committerAleksey Kladov <[email protected]>2019-08-23 14:59:50 +0100
commit5b18a4eef9e69260ce2f105b33553c929cb7d827 (patch)
tree15f55b3eab48c3d0bbb1975fbd4db7cbb56d3e3e /crates/ra_ide_api/src/completion
parentc12dce0073c1766f7d2b10a69f8526a8093e70dc (diff)
rename struct -> record, pos -> tuple
Diffstat (limited to 'crates/ra_ide_api/src/completion')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs2
-rw-r--r--crates/ra_ide_api/src/completion/complete_record_literal.rs (renamed from crates/ra_ide_api/src/completion/complete_struct_literal.rs)14
-rw-r--r--crates/ra_ide_api/src/completion/complete_record_pattern.rs (renamed from crates/ra_ide_api/src/completion/complete_struct_pattern.rs)10
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs16
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs2
5 files changed, 22 insertions, 22 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index d43ff2eec..27256f879 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -45,7 +45,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
45 // FIXME unions 45 // FIXME unions
46 TypeCtor::Tuple { .. } => { 46 TypeCtor::Tuple { .. } => {
47 for (i, ty) in a_ty.parameters.iter().enumerate() { 47 for (i, ty) in a_ty.parameters.iter().enumerate() {
48 acc.add_pos_field(ctx, i, ty); 48 acc.add_tuple_field(ctx, i, ty);
49 } 49 }
50 } 50 }
51 _ => {} 51 _ => {}
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_record_literal.rs
index 6aa41f498..6b929a8ac 100644
--- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs
+++ b/crates/ra_ide_api/src/completion/complete_record_literal.rs
@@ -3,11 +3,11 @@ use hir::Substs;
3use crate::completion::{CompletionContext, Completions}; 3use crate::completion::{CompletionContext, Completions};
4 4
5/// Complete fields in fields literals. 5/// Complete fields in fields literals.
6pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { 6pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionContext) {
7 let (ty, variant) = match ctx.struct_lit_syntax.as_ref().and_then(|it| { 7 let (ty, variant) = match ctx.record_lit_syntax.as_ref().and_then(|it| {
8 Some(( 8 Some((
9 ctx.analyzer.type_of(ctx.db, &it.clone().into())?, 9 ctx.analyzer.type_of(ctx.db, &it.clone().into())?,
10 ctx.analyzer.resolve_struct_literal(it)?, 10 ctx.analyzer.resolve_record_literal(it)?,
11 )) 11 ))
12 }) { 12 }) {
13 Some(it) => it, 13 Some(it) => it,
@@ -30,7 +30,7 @@ mod tests {
30 } 30 }
31 31
32 #[test] 32 #[test]
33 fn test_struct_literal_field() { 33 fn test_record_literal_field() {
34 let completions = complete( 34 let completions = complete(
35 r" 35 r"
36 struct A { the_field: u32 } 36 struct A { the_field: u32 }
@@ -54,7 +54,7 @@ mod tests {
54 } 54 }
55 55
56 #[test] 56 #[test]
57 fn test_struct_literal_enum_variant() { 57 fn test_record_literal_enum_variant() {
58 let completions = complete( 58 let completions = complete(
59 r" 59 r"
60 enum E { 60 enum E {
@@ -80,7 +80,7 @@ mod tests {
80 } 80 }
81 81
82 #[test] 82 #[test]
83 fn test_struct_literal_two_structs() { 83 fn test_record_literal_two_structs() {
84 let completions = complete( 84 let completions = complete(
85 r" 85 r"
86 struct A { a: u32 } 86 struct A { a: u32 }
@@ -106,7 +106,7 @@ mod tests {
106 } 106 }
107 107
108 #[test] 108 #[test]
109 fn test_struct_literal_generic_struct() { 109 fn test_record_literal_generic_struct() {
110 let completions = complete( 110 let completions = complete(
111 r" 111 r"
112 struct A<T> { a: T } 112 struct A<T> { a: T }
diff --git a/crates/ra_ide_api/src/completion/complete_struct_pattern.rs b/crates/ra_ide_api/src/completion/complete_record_pattern.rs
index d0dde5930..8c8b47ea4 100644
--- a/crates/ra_ide_api/src/completion/complete_struct_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_record_pattern.rs
@@ -2,11 +2,11 @@ use hir::Substs;
2 2
3use crate::completion::{CompletionContext, Completions}; 3use crate::completion::{CompletionContext, Completions};
4 4
5pub(super) fn complete_struct_pattern(acc: &mut Completions, ctx: &CompletionContext) { 5pub(super) fn complete_record_pattern(acc: &mut Completions, ctx: &CompletionContext) {
6 let (ty, variant) = match ctx.struct_lit_pat.as_ref().and_then(|it| { 6 let (ty, variant) = match ctx.record_lit_pat.as_ref().and_then(|it| {
7 Some(( 7 Some((
8 ctx.analyzer.type_of_pat(ctx.db, &it.clone().into())?, 8 ctx.analyzer.type_of_pat(ctx.db, &it.clone().into())?,
9 ctx.analyzer.resolve_struct_pattern(it)?, 9 ctx.analyzer.resolve_record_pattern(it)?,
10 )) 10 ))
11 }) { 11 }) {
12 Some(it) => it, 12 Some(it) => it,
@@ -29,7 +29,7 @@ mod tests {
29 } 29 }
30 30
31 #[test] 31 #[test]
32 fn test_struct_pattern_field() { 32 fn test_record_pattern_field() {
33 let completions = complete( 33 let completions = complete(
34 r" 34 r"
35 struct S { foo: u32 } 35 struct S { foo: u32 }
@@ -56,7 +56,7 @@ mod tests {
56 } 56 }
57 57
58 #[test] 58 #[test]
59 fn test_struct_pattern_enum_variant() { 59 fn test_record_pattern_enum_variant() {
60 let completions = complete( 60 let completions = complete(
61 r" 61 r"
62 enum E { 62 enum E {
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index dfaa9ce69..7139947b3 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -20,8 +20,8 @@ pub(crate) struct CompletionContext<'a> {
20 pub(super) module: Option<hir::Module>, 20 pub(super) module: Option<hir::Module>,
21 pub(super) function_syntax: Option<ast::FnDef>, 21 pub(super) function_syntax: Option<ast::FnDef>,
22 pub(super) use_item_syntax: Option<ast::UseItem>, 22 pub(super) use_item_syntax: Option<ast::UseItem>,
23 pub(super) struct_lit_syntax: Option<ast::StructLit>, 23 pub(super) record_lit_syntax: Option<ast::RecordLit>,
24 pub(super) struct_lit_pat: Option<ast::StructPat>, 24 pub(super) record_lit_pat: Option<ast::RecordPat>,
25 pub(super) is_param: bool, 25 pub(super) is_param: bool,
26 /// If a name-binding or reference to a const in a pattern. 26 /// If a name-binding or reference to a const in a pattern.
27 /// Irrefutable patterns (like let) are excluded. 27 /// Irrefutable patterns (like let) are excluded.
@@ -60,8 +60,8 @@ impl<'a> CompletionContext<'a> {
60 module, 60 module,
61 function_syntax: None, 61 function_syntax: None,
62 use_item_syntax: None, 62 use_item_syntax: None,
63 struct_lit_syntax: None, 63 record_lit_syntax: None,
64 struct_lit_pat: None, 64 record_lit_pat: None,
65 is_param: false, 65 is_param: false,
66 is_pat_binding: false, 66 is_pat_binding: false,
67 is_trivial_path: false, 67 is_trivial_path: false,
@@ -120,8 +120,8 @@ impl<'a> CompletionContext<'a> {
120 self.is_param = true; 120 self.is_param = true;
121 return; 121 return;
122 } 122 }
123 if name.syntax().ancestors().find_map(ast::FieldPatList::cast).is_some() { 123 if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() {
124 self.struct_lit_pat = 124 self.record_lit_pat =
125 find_node_at_offset(original_parse.tree().syntax(), self.offset); 125 find_node_at_offset(original_parse.tree().syntax(), self.offset);
126 } 126 }
127 } 127 }
@@ -129,8 +129,8 @@ impl<'a> CompletionContext<'a> {
129 129
130 fn classify_name_ref(&mut self, original_file: SourceFile, name_ref: ast::NameRef) { 130 fn classify_name_ref(&mut self, original_file: SourceFile, name_ref: ast::NameRef) {
131 let name_range = name_ref.syntax().text_range(); 131 let name_range = name_ref.syntax().text_range();
132 if name_ref.syntax().parent().and_then(ast::NamedField::cast).is_some() { 132 if name_ref.syntax().parent().and_then(ast::RecordField::cast).is_some() {
133 self.struct_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); 133 self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);
134 } 134 }
135 135
136 let top_node = name_ref 136 let top_node = name_ref
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index 2b3f98482..147ceda0c 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -28,7 +28,7 @@ impl Completions {
28 .add_to(self); 28 .add_to(self);
29 } 29 }
30 30
31 pub(crate) fn add_pos_field(&mut self, ctx: &CompletionContext, field: usize, ty: &hir::Ty) { 31 pub(crate) fn add_tuple_field(&mut self, ctx: &CompletionContext, field: usize, ty: &hir::Ty) {
32 CompletionItem::new(CompletionKind::Reference, ctx.source_range(), field.to_string()) 32 CompletionItem::new(CompletionKind::Reference, ctx.source_range(), field.to_string())
33 .kind(CompletionItemKind::Field) 33 .kind(CompletionItemKind::Field)
34 .detail(ty.display(ctx.db).to_string()) 34 .detail(ty.display(ctx.db).to_string())