diff options
author | Florian Diebold <[email protected]> | 2019-01-12 20:58:16 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-01-12 20:58:16 +0000 |
commit | 1ed7fbfc1badd2c2a42b4dc2feb1b4bf7835d3ef (patch) | |
tree | 8e0a5cd3e1981bf0ff9615636d45566dd85fdb97 /crates | |
parent | 5db5f5cc1dc5dfbded866b59570afc50538b9091 (diff) |
args -> params
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function/scope.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 26 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 2 |
8 files changed, 37 insertions, 37 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 9c28b62af..91b235594 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -273,11 +273,11 @@ pub use crate::code_model_impl::function::ScopeEntryWithSyntax; | |||
273 | #[derive(Debug, Clone, PartialEq, Eq)] | 273 | #[derive(Debug, Clone, PartialEq, Eq)] |
274 | pub struct FnSignature { | 274 | pub struct FnSignature { |
275 | pub(crate) name: Name, | 275 | pub(crate) name: Name, |
276 | pub(crate) args: Vec<TypeRef>, | 276 | pub(crate) params: Vec<TypeRef>, |
277 | pub(crate) ret_type: TypeRef, | 277 | pub(crate) ret_type: TypeRef, |
278 | /// True if the first arg is `self`. This is relevant to decide whether this | 278 | /// True if the first param is `self`. This is relevant to decide whether this |
279 | /// can be called as a method. | 279 | /// can be called as a method. |
280 | pub(crate) has_self_arg: bool, | 280 | pub(crate) has_self_param: bool, |
281 | } | 281 | } |
282 | 282 | ||
283 | impl FnSignature { | 283 | impl FnSignature { |
@@ -285,8 +285,8 @@ impl FnSignature { | |||
285 | &self.name | 285 | &self.name |
286 | } | 286 | } |
287 | 287 | ||
288 | pub fn args(&self) -> &[TypeRef] { | 288 | pub fn params(&self) -> &[TypeRef] { |
289 | &self.args | 289 | &self.params |
290 | } | 290 | } |
291 | 291 | ||
292 | pub fn ret_type(&self) -> &TypeRef { | 292 | pub fn ret_type(&self) -> &TypeRef { |
@@ -295,8 +295,8 @@ impl FnSignature { | |||
295 | 295 | ||
296 | /// True if the first arg is `self`. This is relevant to decide whether this | 296 | /// True if the first arg is `self`. This is relevant to decide whether this |
297 | /// can be called as a method. | 297 | /// can be called as a method. |
298 | pub fn has_self_arg(&self) -> bool { | 298 | pub fn has_self_param(&self) -> bool { |
299 | self.has_self_arg | 299 | self.has_self_param |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index 77dddff79..8d6b7fc19 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs | |||
@@ -42,8 +42,8 @@ impl FnSignature { | |||
42 | .name() | 42 | .name() |
43 | .map(|n| n.as_name()) | 43 | .map(|n| n.as_name()) |
44 | .unwrap_or_else(Name::missing); | 44 | .unwrap_or_else(Name::missing); |
45 | let mut args = Vec::new(); | 45 | let mut params = Vec::new(); |
46 | let mut has_self_arg = false; | 46 | let mut has_self_param = false; |
47 | if let Some(param_list) = node.param_list() { | 47 | if let Some(param_list) = node.param_list() { |
48 | if let Some(self_param) = param_list.self_param() { | 48 | if let Some(self_param) = param_list.self_param() { |
49 | let self_type = if let Some(type_ref) = self_param.type_ref() { | 49 | let self_type = if let Some(type_ref) = self_param.type_ref() { |
@@ -60,12 +60,12 @@ impl FnSignature { | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | }; | 62 | }; |
63 | args.push(self_type); | 63 | params.push(self_type); |
64 | has_self_arg = true; | 64 | has_self_param = true; |
65 | } | 65 | } |
66 | for param in param_list.params() { | 66 | for param in param_list.params() { |
67 | let type_ref = TypeRef::from_ast_opt(param.type_ref()); | 67 | let type_ref = TypeRef::from_ast_opt(param.type_ref()); |
68 | args.push(type_ref); | 68 | params.push(type_ref); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | let ret_type = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) { | 71 | let ret_type = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) { |
@@ -75,9 +75,9 @@ impl FnSignature { | |||
75 | }; | 75 | }; |
76 | let sig = FnSignature { | 76 | let sig = FnSignature { |
77 | name, | 77 | name, |
78 | args, | 78 | params, |
79 | ret_type, | 79 | ret_type, |
80 | has_self_arg, | 80 | has_self_param, |
81 | }; | 81 | }; |
82 | Arc::new(sig) | 82 | Arc::new(sig) |
83 | } | 83 | } |
diff --git a/crates/ra_hir/src/code_model_impl/function/scope.rs b/crates/ra_hir/src/code_model_impl/function/scope.rs index ebf6edc1b..7d938c0dd 100644 --- a/crates/ra_hir/src/code_model_impl/function/scope.rs +++ b/crates/ra_hir/src/code_model_impl/function/scope.rs | |||
@@ -43,7 +43,7 @@ impl FnScopes { | |||
43 | scope_for: FxHashMap::default(), | 43 | scope_for: FxHashMap::default(), |
44 | }; | 44 | }; |
45 | let root = scopes.root_scope(); | 45 | let root = scopes.root_scope(); |
46 | scopes.add_params_bindings(root, body.args()); | 46 | scopes.add_params_bindings(root, body.params()); |
47 | compute_expr_scopes(body.body_expr(), &body, &mut scopes, root); | 47 | compute_expr_scopes(body.body_expr(), &body, &mut scopes, root); |
48 | scopes | 48 | scopes |
49 | } | 49 | } |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index e5596cbaa..67e123e4d 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -18,13 +18,13 @@ impl_arena_id!(ExprId); | |||
18 | pub struct Body { | 18 | pub struct Body { |
19 | exprs: Arena<ExprId, Expr>, | 19 | exprs: Arena<ExprId, Expr>, |
20 | pats: Arena<PatId, Pat>, | 20 | pats: Arena<PatId, Pat>, |
21 | /// The patterns for the function's arguments. While the argument types are | 21 | /// The patterns for the function's parameters. While the parameter types are |
22 | /// part of the function signature, the patterns are not (they don't change | 22 | /// part of the function signature, the patterns are not (they don't change |
23 | /// the external type of the function). | 23 | /// the external type of the function). |
24 | /// | 24 | /// |
25 | /// If this `Body` is for the body of a constant, this will just be | 25 | /// If this `Body` is for the body of a constant, this will just be |
26 | /// empty. | 26 | /// empty. |
27 | args: Vec<PatId>, | 27 | params: Vec<PatId>, |
28 | /// The `ExprId` of the actual body expression. | 28 | /// The `ExprId` of the actual body expression. |
29 | body_expr: ExprId, | 29 | body_expr: ExprId, |
30 | } | 30 | } |
@@ -44,8 +44,8 @@ pub struct BodySyntaxMapping { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | impl Body { | 46 | impl Body { |
47 | pub fn args(&self) -> &[PatId] { | 47 | pub fn params(&self) -> &[PatId] { |
48 | &self.args | 48 | &self.params |
49 | } | 49 | } |
50 | 50 | ||
51 | pub fn body_expr(&self) -> ExprId { | 51 | pub fn body_expr(&self) -> ExprId { |
@@ -699,11 +699,11 @@ impl ExprCollector { | |||
699 | } | 699 | } |
700 | } | 700 | } |
701 | 701 | ||
702 | fn into_body_syntax_mapping(self, args: Vec<PatId>, body_expr: ExprId) -> BodySyntaxMapping { | 702 | fn into_body_syntax_mapping(self, params: Vec<PatId>, body_expr: ExprId) -> BodySyntaxMapping { |
703 | let body = Body { | 703 | let body = Body { |
704 | exprs: self.exprs, | 704 | exprs: self.exprs, |
705 | pats: self.pats, | 705 | pats: self.pats, |
706 | args, | 706 | params, |
707 | body_expr, | 707 | body_expr, |
708 | }; | 708 | }; |
709 | BodySyntaxMapping { | 709 | BodySyntaxMapping { |
@@ -719,8 +719,8 @@ impl ExprCollector { | |||
719 | pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { | 719 | pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { |
720 | let mut collector = ExprCollector::new(); | 720 | let mut collector = ExprCollector::new(); |
721 | 721 | ||
722 | let args = if let Some(param_list) = node.param_list() { | 722 | let params = if let Some(param_list) = node.param_list() { |
723 | let mut args = Vec::new(); | 723 | let mut params = Vec::new(); |
724 | 724 | ||
725 | if let Some(self_param) = param_list.self_param() { | 725 | if let Some(self_param) = param_list.self_param() { |
726 | let self_param = LocalSyntaxPtr::new( | 726 | let self_param = LocalSyntaxPtr::new( |
@@ -729,13 +729,13 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { | |||
729 | .expect("self param without self keyword") | 729 | .expect("self param without self keyword") |
730 | .syntax(), | 730 | .syntax(), |
731 | ); | 731 | ); |
732 | let arg = collector.alloc_pat( | 732 | let param = collector.alloc_pat( |
733 | Pat::Bind { | 733 | Pat::Bind { |
734 | name: Name::self_param(), | 734 | name: Name::self_param(), |
735 | }, | 735 | }, |
736 | self_param, | 736 | self_param, |
737 | ); | 737 | ); |
738 | args.push(arg); | 738 | params.push(param); |
739 | } | 739 | } |
740 | 740 | ||
741 | for param in param_list.params() { | 741 | for param in param_list.params() { |
@@ -744,15 +744,15 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { | |||
744 | } else { | 744 | } else { |
745 | continue; | 745 | continue; |
746 | }; | 746 | }; |
747 | args.push(collector.collect_pat(pat)); | 747 | params.push(collector.collect_pat(pat)); |
748 | } | 748 | } |
749 | args | 749 | params |
750 | } else { | 750 | } else { |
751 | Vec::new() | 751 | Vec::new() |
752 | }; | 752 | }; |
753 | 753 | ||
754 | let body = collector.collect_block_opt(node.body()); | 754 | let body = collector.collect_block_opt(node.body()); |
755 | collector.into_body_syntax_mapping(args, body) | 755 | collector.into_body_syntax_mapping(params, body) |
756 | } | 756 | } |
757 | 757 | ||
758 | pub(crate) fn body_syntax_mapping( | 758 | pub(crate) fn body_syntax_mapping( |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 2dcba5283..5d5568d69 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -432,7 +432,7 @@ fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> { | |||
432 | let impl_block = f.impl_block(db)?; | 432 | let impl_block = f.impl_block(db)?; |
433 | // TODO we ignore type parameters for now | 433 | // TODO we ignore type parameters for now |
434 | let input = signature | 434 | let input = signature |
435 | .args() | 435 | .params() |
436 | .iter() | 436 | .iter() |
437 | .map(|tr| Ty::from_hir(db, &module, impl_block.as_ref(), tr)) | 437 | .map(|tr| Ty::from_hir(db, &module, impl_block.as_ref(), tr)) |
438 | .collect::<Cancelable<Vec<_>>>()?; | 438 | .collect::<Cancelable<Vec<_>>>()?; |
@@ -876,7 +876,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
876 | } | 876 | } |
877 | Expr::Call { callee, args } => { | 877 | Expr::Call { callee, args } => { |
878 | let callee_ty = self.infer_expr(*callee, &Expectation::none())?; | 878 | let callee_ty = self.infer_expr(*callee, &Expectation::none())?; |
879 | let (arg_tys, ret_ty) = match &callee_ty { | 879 | let (param_tys, ret_ty) = match &callee_ty { |
880 | Ty::FnPtr(sig) => (&sig.input[..], sig.output.clone()), | 880 | Ty::FnPtr(sig) => (&sig.input[..], sig.output.clone()), |
881 | _ => { | 881 | _ => { |
882 | // not callable | 882 | // not callable |
@@ -887,7 +887,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
887 | for (i, arg) in args.iter().enumerate() { | 887 | for (i, arg) in args.iter().enumerate() { |
888 | self.infer_expr( | 888 | self.infer_expr( |
889 | *arg, | 889 | *arg, |
890 | &Expectation::has_type(arg_tys.get(i).cloned().unwrap_or(Ty::Unknown)), | 890 | &Expectation::has_type(param_tys.get(i).cloned().unwrap_or(Ty::Unknown)), |
891 | )?; | 891 | )?; |
892 | } | 892 | } |
893 | ret_ty | 893 | ret_ty |
@@ -904,7 +904,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
904 | None => Ty::Unknown, | 904 | None => Ty::Unknown, |
905 | }; | 905 | }; |
906 | let method_ty = self.insert_type_vars(method_ty); | 906 | let method_ty = self.insert_type_vars(method_ty); |
907 | let (expected_receiver_ty, arg_tys, ret_ty) = match &method_ty { | 907 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { |
908 | Ty::FnPtr(sig) => { | 908 | Ty::FnPtr(sig) => { |
909 | if sig.input.len() > 0 { | 909 | if sig.input.len() > 0 { |
910 | (&sig.input[0], &sig.input[1..], sig.output.clone()) | 910 | (&sig.input[0], &sig.input[1..], sig.output.clone()) |
@@ -920,7 +920,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
920 | for (i, arg) in args.iter().enumerate() { | 920 | for (i, arg) in args.iter().enumerate() { |
921 | self.infer_expr( | 921 | self.infer_expr( |
922 | *arg, | 922 | *arg, |
923 | &Expectation::has_type(arg_tys.get(i).cloned().unwrap_or(Ty::Unknown)), | 923 | &Expectation::has_type(param_tys.get(i).cloned().unwrap_or(Ty::Unknown)), |
924 | )?; | 924 | )?; |
925 | } | 925 | } |
926 | ret_ty | 926 | ret_ty |
@@ -1093,7 +1093,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1093 | 1093 | ||
1094 | fn collect_fn_signature(&mut self, signature: &FnSignature) -> Cancelable<()> { | 1094 | fn collect_fn_signature(&mut self, signature: &FnSignature) -> Cancelable<()> { |
1095 | let body = Arc::clone(&self.body); // avoid borrow checker problem | 1095 | let body = Arc::clone(&self.body); // avoid borrow checker problem |
1096 | for (type_ref, pat) in signature.args().iter().zip(body.args()) { | 1096 | for (type_ref, pat) in signature.params().iter().zip(body.params()) { |
1097 | let ty = self.make_ty(type_ref)?; | 1097 | let ty = self.make_ty(type_ref)?; |
1098 | let ty = self.insert_type_vars(ty); | 1098 | let ty = self.insert_type_vars(ty); |
1099 | self.write_pat_ty(*pat, ty); | 1099 | self.write_pat_ty(*pat, ty); |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 1330d03a8..7c3839388 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -114,7 +114,7 @@ impl Ty { | |||
114 | pub fn lookup_method(self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<DefId>> { | 114 | pub fn lookup_method(self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<DefId>> { |
115 | self.iterate_methods(db, |f| { | 115 | self.iterate_methods(db, |f| { |
116 | let sig = f.signature(db); | 116 | let sig = f.signature(db); |
117 | if sig.name() == name && sig.has_self_arg() { | 117 | if sig.name() == name && sig.has_self_param() { |
118 | Ok(Some(f.def_id())) | 118 | Ok(Some(f.def_id())) |
119 | } else { | 119 | } else { |
120 | Ok(None) | 120 | Ok(None) |
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 9b01eb0ab..37985b398 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -63,7 +63,7 @@ fn complete_methods( | |||
63 | ) -> Cancelable<()> { | 63 | ) -> Cancelable<()> { |
64 | receiver.iterate_methods(ctx.db, |func| { | 64 | receiver.iterate_methods(ctx.db, |func| { |
65 | let sig = func.signature(ctx.db); | 65 | let sig = func.signature(ctx.db); |
66 | if sig.has_self_arg() { | 66 | if sig.has_self_param() { |
67 | CompletionItem::new(CompletionKind::Reference, sig.name().to_string()) | 67 | CompletionItem::new(CompletionKind::Reference, sig.name().to_string()) |
68 | .from_function(ctx, func) | 68 | .from_function(ctx, func) |
69 | .kind(CompletionItemKind::Method) | 69 | .kind(CompletionItemKind::Method) |
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 9ce778487..b75d65de3 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -191,7 +191,7 @@ impl Builder { | |||
191 | ) -> Builder { | 191 | ) -> Builder { |
192 | // If not an import, add parenthesis automatically. | 192 | // If not an import, add parenthesis automatically. |
193 | if ctx.use_item_syntax.is_none() && !ctx.is_call { | 193 | if ctx.use_item_syntax.is_none() && !ctx.is_call { |
194 | if function.signature(ctx.db).args().is_empty() { | 194 | if function.signature(ctx.db).params().is_empty() { |
195 | self.snippet = Some(format!("{}()$0", self.label)); | 195 | self.snippet = Some(format!("{}()$0", self.label)); |
196 | } else { | 196 | } else { |
197 | self.snippet = Some(format!("{}($0)", self.label)); | 197 | self.snippet = Some(format!("{}($0)", self.label)); |