From 1ed7fbfc1badd2c2a42b4dc2feb1b4bf7835d3ef Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 12 Jan 2019 21:58:16 +0100 Subject: args -> params --- crates/ra_hir/src/code_model_api.rs | 14 ++++++------ crates/ra_hir/src/code_model_impl/function.rs | 14 ++++++------ .../ra_hir/src/code_model_impl/function/scope.rs | 2 +- crates/ra_hir/src/expr.rs | 26 +++++++++++----------- crates/ra_hir/src/ty.rs | 12 +++++----- crates/ra_hir/src/ty/method_resolution.rs | 2 +- crates/ra_ide_api/src/completion/complete_dot.rs | 2 +- .../ra_ide_api/src/completion/completion_item.rs | 2 +- 8 files changed, 37 insertions(+), 37 deletions(-) (limited to 'crates') 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; #[derive(Debug, Clone, PartialEq, Eq)] pub struct FnSignature { pub(crate) name: Name, - pub(crate) args: Vec, + pub(crate) params: Vec, pub(crate) ret_type: TypeRef, - /// True if the first arg is `self`. This is relevant to decide whether this + /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. - pub(crate) has_self_arg: bool, + pub(crate) has_self_param: bool, } impl FnSignature { @@ -285,8 +285,8 @@ impl FnSignature { &self.name } - pub fn args(&self) -> &[TypeRef] { - &self.args + pub fn params(&self) -> &[TypeRef] { + &self.params } pub fn ret_type(&self) -> &TypeRef { @@ -295,8 +295,8 @@ impl FnSignature { /// True if the first arg is `self`. This is relevant to decide whether this /// can be called as a method. - pub fn has_self_arg(&self) -> bool { - self.has_self_arg + pub fn has_self_param(&self) -> bool { + self.has_self_param } } 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 { .name() .map(|n| n.as_name()) .unwrap_or_else(Name::missing); - let mut args = Vec::new(); - let mut has_self_arg = false; + let mut params = Vec::new(); + let mut has_self_param = false; if let Some(param_list) = node.param_list() { if let Some(self_param) = param_list.self_param() { let self_type = if let Some(type_ref) = self_param.type_ref() { @@ -60,12 +60,12 @@ impl FnSignature { } } }; - args.push(self_type); - has_self_arg = true; + params.push(self_type); + has_self_param = true; } for param in param_list.params() { let type_ref = TypeRef::from_ast_opt(param.type_ref()); - args.push(type_ref); + params.push(type_ref); } } let ret_type = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) { @@ -75,9 +75,9 @@ impl FnSignature { }; let sig = FnSignature { name, - args, + params, ret_type, - has_self_arg, + has_self_param, }; Arc::new(sig) } 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 { scope_for: FxHashMap::default(), }; let root = scopes.root_scope(); - scopes.add_params_bindings(root, body.args()); + scopes.add_params_bindings(root, body.params()); compute_expr_scopes(body.body_expr(), &body, &mut scopes, root); scopes } 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); pub struct Body { exprs: Arena, pats: Arena, - /// The patterns for the function's arguments. While the argument types are + /// The patterns for the function's parameters. While the parameter types are /// part of the function signature, the patterns are not (they don't change /// the external type of the function). /// /// If this `Body` is for the body of a constant, this will just be /// empty. - args: Vec, + params: Vec, /// The `ExprId` of the actual body expression. body_expr: ExprId, } @@ -44,8 +44,8 @@ pub struct BodySyntaxMapping { } impl Body { - pub fn args(&self) -> &[PatId] { - &self.args + pub fn params(&self) -> &[PatId] { + &self.params } pub fn body_expr(&self) -> ExprId { @@ -699,11 +699,11 @@ impl ExprCollector { } } - fn into_body_syntax_mapping(self, args: Vec, body_expr: ExprId) -> BodySyntaxMapping { + fn into_body_syntax_mapping(self, params: Vec, body_expr: ExprId) -> BodySyntaxMapping { let body = Body { exprs: self.exprs, pats: self.pats, - args, + params, body_expr, }; BodySyntaxMapping { @@ -719,8 +719,8 @@ impl ExprCollector { pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { let mut collector = ExprCollector::new(); - let args = if let Some(param_list) = node.param_list() { - let mut args = Vec::new(); + let params = if let Some(param_list) = node.param_list() { + let mut params = Vec::new(); if let Some(self_param) = param_list.self_param() { let self_param = LocalSyntaxPtr::new( @@ -729,13 +729,13 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { .expect("self param without self keyword") .syntax(), ); - let arg = collector.alloc_pat( + let param = collector.alloc_pat( Pat::Bind { name: Name::self_param(), }, self_param, ); - args.push(arg); + params.push(param); } for param in param_list.params() { @@ -744,15 +744,15 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { } else { continue; }; - args.push(collector.collect_pat(pat)); + params.push(collector.collect_pat(pat)); } - args + params } else { Vec::new() }; let body = collector.collect_block_opt(node.body()); - collector.into_body_syntax_mapping(args, body) + collector.into_body_syntax_mapping(params, body) } 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 { let impl_block = f.impl_block(db)?; // TODO we ignore type parameters for now let input = signature - .args() + .params() .iter() .map(|tr| Ty::from_hir(db, &module, impl_block.as_ref(), tr)) .collect::>>()?; @@ -876,7 +876,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } Expr::Call { callee, args } => { let callee_ty = self.infer_expr(*callee, &Expectation::none())?; - let (arg_tys, ret_ty) = match &callee_ty { + let (param_tys, ret_ty) = match &callee_ty { Ty::FnPtr(sig) => (&sig.input[..], sig.output.clone()), _ => { // not callable @@ -887,7 +887,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { for (i, arg) in args.iter().enumerate() { self.infer_expr( *arg, - &Expectation::has_type(arg_tys.get(i).cloned().unwrap_or(Ty::Unknown)), + &Expectation::has_type(param_tys.get(i).cloned().unwrap_or(Ty::Unknown)), )?; } ret_ty @@ -904,7 +904,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { None => Ty::Unknown, }; let method_ty = self.insert_type_vars(method_ty); - let (expected_receiver_ty, arg_tys, ret_ty) = match &method_ty { + let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { Ty::FnPtr(sig) => { if sig.input.len() > 0 { (&sig.input[0], &sig.input[1..], sig.output.clone()) @@ -920,7 +920,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { for (i, arg) in args.iter().enumerate() { self.infer_expr( *arg, - &Expectation::has_type(arg_tys.get(i).cloned().unwrap_or(Ty::Unknown)), + &Expectation::has_type(param_tys.get(i).cloned().unwrap_or(Ty::Unknown)), )?; } ret_ty @@ -1093,7 +1093,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { fn collect_fn_signature(&mut self, signature: &FnSignature) -> Cancelable<()> { let body = Arc::clone(&self.body); // avoid borrow checker problem - for (type_ref, pat) in signature.args().iter().zip(body.args()) { + for (type_ref, pat) in signature.params().iter().zip(body.params()) { let ty = self.make_ty(type_ref)?; let ty = self.insert_type_vars(ty); 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 { pub fn lookup_method(self, db: &impl HirDatabase, name: &Name) -> Cancelable> { self.iterate_methods(db, |f| { let sig = f.signature(db); - if sig.name() == name && sig.has_self_arg() { + if sig.name() == name && sig.has_self_param() { Ok(Some(f.def_id())) } else { 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( ) -> Cancelable<()> { receiver.iterate_methods(ctx.db, |func| { let sig = func.signature(ctx.db); - if sig.has_self_arg() { + if sig.has_self_param() { CompletionItem::new(CompletionKind::Reference, sig.name().to_string()) .from_function(ctx, func) .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 { ) -> Builder { // If not an import, add parenthesis automatically. if ctx.use_item_syntax.is_none() && !ctx.is_call { - if function.signature(ctx.db).args().is_empty() { + if function.signature(ctx.db).params().is_empty() { self.snippet = Some(format!("{}()$0", self.label)); } else { self.snippet = Some(format!("{}($0)", self.label)); -- cgit v1.2.3