···20532053 // Remap the pipe function type into just the type expected by the pipe.
20542054 let expected = expected
20552055 .fn_types()
20562056- .and_then(|(args, _)| args.first().cloned());
20562056+ .and_then(|(arguments, _)| arguments.first().cloned());
2057205720582058 // Remap the argument as well, if it's a function.
20592059 let given = given
20602060 .fn_types()
20612061- .and_then(|(args, _)| args.first().cloned())
20612061+ .and_then(|(arguments, _)| arguments.first().cloned())
20622062 .unwrap_or_else(|| given.clone());
2063206320642064 let mut printer = Printer::new(names);
···1717pub fn for_expression(expr: &TypedExpr) -> Option<SignatureHelp> {
1818 // If we're inside a function call we can provide signature help,
1919 // otherwise we don't want anything to pop up.
2020- let TypedExpr::Call { fun, args, .. } = expr else {
2020+ let TypedExpr::Call { fun, arguments, .. } = expr else {
2121 return None;
2222 };
2323···2727 // help.
2828 TypedExpr::Var {
2929 constructor, name, ..
3030- } => signature_help(name.clone(), fun, args, constructor.field_map()),
3030+ } => signature_help(name.clone(), fun, arguments, constructor.field_map()),
31313232 // If we're making a qualified call to another module's function
3333 // then we want to show its type, documentation and the exact name
···5050 | ModuleValueConstructor::Fn { field_map, .. } => field_map.into(),
5151 };
5252 let name = format!("{module_alias}.{label}").into();
5353- signature_help(name, fun, args, field_map)
5353+ signature_help(name, fun, arguments, field_map)
5454 }
55555656 // If the function bein called is an invalid node we don't want to
···6767 // ^ When the cursor is here we are going to show
6868 // "fn(a: a) -> a" as the help signature.
6969 //
7070- _ => signature_help("fn".into(), fun, args, None),
7070+ _ => signature_help("fn".into(), fun, arguments, None),
7171 }
7272}
7373···7777///
7878/// - `fun_name` is used as the display name of the function in the help
7979/// signature.
8080-/// - `supplied_args` are arguments being passed to the function call, those
8080+/// - `supplied_arguments` are arguments being passed to the function call, those
8181/// might not be of the correct arity or have wrong types but are used to
8282/// deduce which argument should be highlighted next in the help signature.
8383/// - `field_map` is the function's field map (if any) that will be used to
···8787fn signature_help(
8888 fun_name: EcoString,
8989 fun: &TypedExpr,
9090- supplied_args: &[CallArg<TypedExpr>],
9090+ supplied_arguments: &[CallArg<TypedExpr>],
9191 field_map: Option<&FieldMap>,
9292) -> Option<SignatureHelp> {
9393- let (args, return_) = fun.type_().fn_types()?;
9393+ let (arguments, return_) = fun.type_().fn_types()?;
94949595 // If the function has no arguments, we don't want to show any help.
9696- let arity = args.len() as u32;
9696+ let arity = arguments.len() as u32;
9797 if arity == 0 {
9898 return None;
9999 }
···109109110110 let printer = Printer::new();
111111 let (label, parameters) =
112112- print_signature_help(printer, fun_name, args, return_, &index_to_label);
112112+ print_signature_help(printer, fun_name, arguments, return_, &index_to_label);
113113114114- let active_parameter = active_parameter_index(arity, supplied_args, index_to_label)
114114+ let active_parameter = active_parameter_index(arity, supplied_arguments, index_to_label)
115115 // If we don't want to highlight any arg in the suggestion we have to
116116 // explicitly provide an out of bound index.
117117 .or(Some(arity));
···135135136136fn active_parameter_index(
137137 arity: u32,
138138- supplied_args: &[CallArg<TypedExpr>],
138138+ supplied_arguments: &[CallArg<TypedExpr>],
139139 mut index_to_label: HashMap<u32, &EcoString>,
140140) -> Option<u32> {
141141 let mut is_use_call = false;
142142- let mut found_labelled_arg = false;
142142+ let mut found_labelled_argument = false;
143143 let mut used_labels = HashSet::new();
144144145145- let mut supplied_unlabelled_args = 0;
146146- let unlabelled_args = arity - index_to_label.len() as u32;
145145+ let mut supplied_unlabelled_arguments = 0;
146146+ let unlabelled_arguments = arity - index_to_label.len() as u32;
147147148148- for (i, arg) in supplied_args.iter().enumerate() {
148148+ for (i, arg) in supplied_arguments.iter().enumerate() {
149149 // If there's an unlabelled argument after a labelled one, we can't
150150 // figure out what to suggest since arguments were passed in a wrong
151151 // order.
152152- if found_labelled_arg && arg.label.is_none() && !arg.is_implicit() {
152152+ if found_labelled_argument && arg.label.is_none() && !arg.is_implicit() {
153153 return None;
154154 }
155155···166166167167 match &arg.label {
168168 Some(label) => {
169169- found_labelled_arg = true;
169169+ found_labelled_argument = true;
170170 let _ = used_labels.insert(label);
171171 }
172172···174174 // corresponding to it from the field map since it has already been
175175 // passed as an unlabelled argument.
176176 None => {
177177- supplied_unlabelled_args += 1;
177177+ supplied_unlabelled_arguments += 1;
178178 let _ = index_to_label.remove(&(i as u32));
179179 }
180180 }
181181 }
182182183183- let active_index = if supplied_unlabelled_args < unlabelled_args {
184184- if found_labelled_arg {
183183+ let active_index = if supplied_unlabelled_arguments < unlabelled_arguments {
184184+ if found_labelled_argument {
185185 // If I have supplied some labelled args but I haven't supplied all
186186 // unlabelled args before a labelled one then we can't safely
187187 // suggest anything as the next argument.
···189189 } else {
190190 // If I haven't supplied enough unlabelled arguments then I have to
191191 // set the next one as active (be it labelled or not).
192192- Some(supplied_unlabelled_args)
192192+ Some(supplied_unlabelled_arguments)
193193 }
194194 } else {
195195 // If I have supplied all the unlabelled arguments (and we could have
···200200 .filter(|(_index, label)| !used_labels.contains(label))
201201 .map(|(index, _label)| index)
202202 .min()
203203- .or(Some(supplied_args.len() as u32))
203203+ .or(Some(supplied_arguments.len() as u32))
204204 };
205205206206 // If we're showing hints for a use call and we end up deciding that the
···222222fn print_signature_help(
223223 mut printer: Printer,
224224 function_name: EcoString,
225225- args: Vec<Arc<Type>>,
225225+ arguments: Vec<Arc<Type>>,
226226 return_: Arc<Type>,
227227 index_to_label: &HashMap<u32, &EcoString>,
228228) -> (String, Vec<ParameterInformation>) {
229229- let args_count = args.len();
229229+ let arguments_count = arguments.len();
230230 let mut signature = format!("{function_name}(");
231231- let mut parameter_informations = Vec::with_capacity(args_count);
231231+ let mut parameter_informations = Vec::with_capacity(arguments_count);
232232233233- for (i, arg) in args.iter().enumerate() {
233233+ for (i, argument) in arguments.iter().enumerate() {
234234 let arg_start = signature.len();
235235 if let Some(label) = index_to_label.get(&(i as u32)) {
236236 signature.push_str(label);
237237 signature.push_str(": ");
238238 }
239239- signature.push_str(&printer.pretty_print(arg, 0));
239239+ signature.push_str(&printer.pretty_print(argument, 0));
240240 let arg_end = signature.len();
241241 let label = ParameterLabel::LabelOffsets([arg_start as u32, arg_end as u32]);
242242···245245 documentation: None,
246246 });
247247248248- let is_last = i == args_count - 1;
248248+ let is_last = i == arguments_count - 1;
249249 if !is_last {
250250 signature.push_str(", ");
251251 }
···4444 ///
4545 pub fn reorder<A>(
4646 &self,
4747- args: &mut Vec<CallArg<A>>,
4747+ arguments: &mut Vec<CallArg<A>>,
4848 location: SrcSpan,
4949 context: IncorrectArityContext,
5050 ) -> Result<(), Error> {
5151 let mut labelled_arguments_given = false;
5252 let mut seen_labels = HashSet::new();
5353 let mut unknown_labels = Vec::new();
5454- let number_of_arguments = args.len();
5454+ let number_of_arguments = arguments.len();
55555656- if self.arity as usize != args.len() {
5656+ if self.arity as usize != arguments.len() {
5757 return Err(Error::IncorrectArity {
5858- labels: self.missing_labels(args),
5858+ labels: self.missing_labels(arguments),
5959 location,
6060 context,
6161 expected: self.arity as usize,
6262- given: args.len(),
6262+ given: arguments.len(),
6363 });
6464 }
65656666- for arg in args.iter() {
6767- match &arg.label {
6666+ for argument in arguments.iter() {
6767+ match &argument.label {
6868 Some(_) => {
6969 labelled_arguments_given = true;
7070 }
71717272 None => {
7373- if labelled_arguments_given && !arg.is_implicit() {
7373+ if labelled_arguments_given && !argument.is_implicit() {
7474 return Err(Error::PositionalArgumentAfterLabelled {
7575- location: arg.location,
7575+ location: argument.location,
7676 });
7777 }
7878 }
···8585 // We iterate the argument in reverse order, because we have to remove elements
8686 // from the `args` list quite a lot, and removing from the end of a list is more
8787 // efficient than removing from the beginning or the middle.
8888- let mut i = args.len();
8888+ let mut i = arguments.len();
8989 while i > 0 {
9090 i -= 1;
9191- let (label, &location) = match &args.get(i).expect("Field indexing to get label").label
9292- {
9393- // A labelled argument, we may need to reposition it
9494- Some(l) => (
9595- l,
9696- &args
9797- .get(i)
9898- .expect("Indexing in labelled field reordering")
9999- .location,
100100- ),
9191+ let (label, &location) =
9292+ match &arguments.get(i).expect("Field indexing to get label").label {
9393+ // A labelled argument, we may need to reposition it
9494+ Some(l) => (
9595+ l,
9696+ &arguments
9797+ .get(i)
9898+ .expect("Indexing in labelled field reordering")
9999+ .location,
100100+ ),
101101102102- // Not a labelled argument
103103- None => {
104104- continue;
105105- }
106106- };
102102+ // Not a labelled argument
103103+ None => {
104104+ continue;
105105+ }
106106+ };
107107108108 let position = match self.fields.get(label) {
109109 None => {
···124124125125 // Add this argument to the `labelled_arguments` map, and remove if from the
126126 // existing arguments list. It will be reinserted later in the correct index
127127- let _ = labelled_arguments.insert(position as usize, args.remove(i));
127127+ let _ = labelled_arguments.insert(position as usize, arguments.remove(i));
128128 }
129129130130 // The labelled arguments must be reinserted in order
131131 for i in 0..number_of_arguments {
132132- if let Some(arg) = labelled_arguments.remove(&i) {
133133- args.insert(i, arg);
132132+ if let Some(argument) = labelled_arguments.remove(&i) {
133133+ arguments.insert(i, argument);
134134 }
135135 }
136136···158158 /// wibble(1, label3: 2) // -> unused labels: [label2]
159159 /// ```
160160 ///
161161- pub fn missing_labels<A>(&self, args: &[CallArg<A>]) -> Vec<EcoString> {
161161+ pub fn missing_labels<A>(&self, arguments: &[CallArg<A>]) -> Vec<EcoString> {
162162 // We need to know how many positional arguments are in the function
163163 // arguments. That's given by the position of the first labelled
164164 // argument; if the first label argument is third, then we know the
···170170 // We need to count how many positional arguments were actually supplied
171171 // in the call, to remove the corresponding labelled arguments that have
172172 // been taken by any positional argument.
173173- let given_positional_arguments = args
173173+ let given_positional_arguments = arguments
174174 .iter()
175175 .filter(|argument| argument.label.is_none() && !argument.is_use_implicit_callback())
176176 .count();
177177178178- let explicit_labels = args
178178+ let explicit_labels = arguments
179179 .iter()
180180 .filter_map(|argument| argument.label.as_ref())
181181 .collect::<HashSet<&EcoString>>();
···999999 type_::Warning::TodoOrPanicUsedAsFunction {
10001000 kind,
10011001 location,
10021002- args_location,
10031003- args,
10021002+ arguments_location,
10031003+ arguments,
10041004 } => {
10051005 let title = match kind {
10061006 TodoOrPanic::Todo => "Todo used as a function".into(),
10071007 TodoOrPanic::Panic => "Panic used as a function".into(),
10081008 };
10091009- let label_location = match args_location {
10091009+ let label_location = match arguments_location {
10101010 None => location,
10111011 Some(location) => location,
10121012 };
···10151015 TodoOrPanic::Panic => "panic",
10161016 };
10171017 let mut text = format!("`{name}` is not a function");
10181018- match args {
10181018+ match arguments {
10191019 0 => text.push_str(&format!(
10201020 ", you can just write `{name}` instead of `{name}()`."
10211021 )),
···10271027 ),
10281028 };
1029102910301030- match args {
10301030+ match arguments {
10311031 0 => {}
10321032 _ => text.push_str(&format!(
10331033 "\n\nHint: if you want to display an error message you should write