From ed800be475c2211f72c3cac84ebb9c00704751e9 Mon Sep 17 00:00:00 2001 From: Adam Welc Date: Mon, 4 Nov 2024 16:52:22 -0800 Subject: [PATCH 1/4] [move-ide] Fixed auto-completion on the dot character --- .../src/analysis/parsing_analysis.rs | 4 +- .../crates/move-compiler/src/expansion/ast.rs | 7 +- .../move-compiler/src/expansion/translate.rs | 18 ++-- .../crates/move-compiler/src/naming/ast.rs | 7 +- .../src/naming/resolve_use_funs.rs | 4 +- .../move-compiler/src/naming/translate.rs | 12 ++- .../crates/move-compiler/src/parser/ast.rs | 9 +- .../crates/move-compiler/src/parser/syntax.rs | 17 ++- .../move-compiler/src/typing/macro_expand.rs | 8 +- .../move-compiler/src/typing/translate.rs | 102 ++++++++++++++---- .../move_2024/ide_mode/dot_incomplete.ide.exp | 12 +++ .../method_and_field_autocomplete.ide.exp | 54 ++++++++++ .../ide_mode/method_autocomplete.ide.exp | 42 ++++++++ .../named_struct_autocomplete.ide.exp | 6 ++ .../named_struct_middle_autocomplete.ide.exp | 6 ++ .../positional_struct_autocomplete.ide.exp | 6 ++ ...struct_method_invalid_autocomplete.ide.exp | 12 +++ .../ide_mode/type_param_autocomplete.ide.exp | 23 ++++ .../type_param_no_autocomplete.ide.exp | 6 ++ .../ide_mode/use_fun_autocomplete.ide.exp | 12 +++ .../named_struct_autocomplete.ide.exp | 6 ++ 21 files changed, 318 insertions(+), 55 deletions(-) diff --git a/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs b/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs index aa390bd839f1a..9eb07f7e35706 100644 --- a/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs +++ b/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs @@ -446,8 +446,8 @@ impl<'a> ParsingAnalysisContext<'a> { self.exp_symbols(e2); } E::Borrow(_, e) => self.exp_symbols(e), - E::Dot(e, _) => self.exp_symbols(e), - E::DotCall(e, name, _, vo, v) => { + E::Dot(e, _, _) => self.exp_symbols(e), + E::DotCall(e, name, _, vo, v, _) => { self.exp_symbols(e); if let Some(v) = vo { v.iter().for_each(|t| self.type_symbols(t)); diff --git a/external-crates/move/crates/move-compiler/src/expansion/ast.rs b/external-crates/move/crates/move-compiler/src/expansion/ast.rs index 9a04042389e1a..78cd54352193e 100644 --- a/external-crates/move/crates/move-compiler/src/expansion/ast.rs +++ b/external-crates/move/crates/move-compiler/src/expansion/ast.rs @@ -336,7 +336,7 @@ pub type LambdaLValues = Spanned; #[allow(clippy::large_enum_variant)] pub enum ExpDotted_ { Exp(Box), - Dot(Box, Name), + Dot(Box, Name, Loc), Index(Box, Spanned>), DotUnresolved(Loc, Box), // dot where Name could not be parsed } @@ -393,6 +393,7 @@ pub enum Exp_ { /* is_macro */ Option, Option>, Spanned>, + Loc, // location of the dot ), Pack(ModuleAccess, Option>, Fields), Vector(Loc, Option>, Spanned>), @@ -1530,7 +1531,7 @@ impl AstDebug for Exp_ { w.comma(rhs, |w, e| e.ast_debug(w)); w.write(")"); } - E::MethodCall(e, f, is_macro, tys_opt, sp!(_, rhs)) => { + E::MethodCall(e, f, is_macro, tys_opt, sp!(_, rhs), _) => { e.ast_debug(w); w.write(format!(".{}", f)); if is_macro.is_some() { @@ -1730,7 +1731,7 @@ impl AstDebug for ExpDotted_ { use ExpDotted_ as D; match self { D::Exp(e) => e.ast_debug(w), - D::Dot(e, n) => { + D::Dot(e, n, _) => { e.ast_debug(w); w.write(format!(".{}", n)) } diff --git a/external-crates/move/crates/move-compiler/src/expansion/translate.rs b/external-crates/move/crates/move-compiler/src/expansion/translate.rs index bf6cf3c020196..2946a425a61ca 100644 --- a/external-crates/move/crates/move-compiler/src/expansion/translate.rs +++ b/external-crates/move/crates/move-compiler/src/expansion/translate.rs @@ -2684,7 +2684,7 @@ fn exp(context: &mut Context, pe: Box) -> Box { EE::UnresolvedError } }, - pdotted_ @ (PE::Dot(_, _) | PE::DotUnresolved(_, _)) => { + pdotted_ @ (PE::Dot(_, _, _) | PE::DotUnresolved(_, _)) => { match exp_dotted(context, Box::new(sp(loc, pdotted_))) { Some(edotted) => EE::ExpDotted(E::DottedUsage::Use, edotted), None => { @@ -2728,14 +2728,14 @@ fn exp(context: &mut Context, pe: Box) -> Box { } } - PE::DotCall(pdotted, n, is_macro, ptys_opt, sp!(rloc, prs)) => { + PE::DotCall(pdotted, n, is_macro, ptys_opt, sp!(rloc, prs), dot_loc) => { match exp_dotted(context, pdotted) { Some(edotted) => { let pkg = context.current_package(); context.check_feature(pkg, FeatureGate::DotCall, loc); let tys_opt = optional_types(context, ptys_opt); let ers = sp(rloc, exps(context, prs)); - EE::MethodCall(edotted, n, is_macro, tys_opt, ers) + EE::MethodCall(edotted, n, is_macro, tys_opt, ers, dot_loc) } None => { assert!(context.env().has_errors()); @@ -2790,8 +2790,8 @@ fn exp_cast(context: &mut Context, in_parens: bool, plhs: Box, pty: P::T | PE::Match(_, _) | PE::Spec(_) => true, - PE::DotCall(lhs, _, _, _, _) - | PE::Dot(lhs, _) + PE::DotCall(lhs, _, _, _, _, _) + | PE::Dot(lhs, _, _) | PE::DotUnresolved(_, lhs) | PE::Index(lhs, _) | PE::Borrow(_, lhs) @@ -2903,7 +2903,7 @@ fn move_or_copy_path_(context: &mut Context, case: PathCase, pe: Box) -> return None; } } - E::ExpDotted_::Dot(_, _) + E::ExpDotted_::Dot(_, _, _) | E::ExpDotted_::DotUnresolved(_, _) | E::ExpDotted_::Index(_, _) => { let current_package = context.current_package(); @@ -2922,9 +2922,9 @@ fn exp_dotted(context: &mut Context, pdotted: Box) -> Option { + PE::Dot(plhs, field, dot_loc) => { let lhs = exp_dotted(context, plhs)?; - EE::Dot(lhs, field) + EE::Dot(lhs, field, dot_loc) } PE::Index(plhs, sp!(argloc, args)) => { let cur_pkg = context.current_package(); @@ -3418,7 +3418,7 @@ fn lvalues(context: &mut Context, e: Box) -> Option { let er = exp(context, pr); L::Mutate(er) } - pdotted_ @ PE::Dot(_, _) => { + pdotted_ @ PE::Dot(_, _, _) => { let dotted = exp_dotted(context, Box::new(sp(loc, pdotted_)))?; L::FieldMutate(dotted) } diff --git a/external-crates/move/crates/move-compiler/src/naming/ast.rs b/external-crates/move/crates/move-compiler/src/naming/ast.rs index aca723dc12584..6acb258426a0b 100644 --- a/external-crates/move/crates/move-compiler/src/naming/ast.rs +++ b/external-crates/move/crates/move-compiler/src/naming/ast.rs @@ -358,7 +358,7 @@ pub type LambdaLValues = Spanned; #[derive(Debug, PartialEq, Clone)] pub enum ExpDotted_ { Exp(Box), - Dot(Box, Field), + Dot(Box, Field, Loc), Index(Box, Spanned>), DotAutocomplete(Loc, Box), // Dot (and its location) where Field could not be parsed } @@ -421,6 +421,7 @@ pub enum Exp_ { /* is_macro */ Option, Option>, Spanned>, + Loc, // location of the dot ), VarCall(Var, Spanned>), Builtin(BuiltinFunction, Spanned>), @@ -1636,7 +1637,7 @@ impl AstDebug for Exp_ { w.comma(rhs, |w, e| e.ast_debug(w)); w.write(")"); } - E::MethodCall(e, f, is_macro, tys_opt, sp!(_, rhs)) => { + E::MethodCall(e, f, is_macro, tys_opt, sp!(_, rhs), _) => { e.ast_debug(w); w.write(format!(".{}", f)); if is_macro.is_some() { @@ -1889,7 +1890,7 @@ impl AstDebug for ExpDotted_ { use ExpDotted_ as D; match self { D::Exp(e) => e.ast_debug(w), - D::Dot(e, n) => { + D::Dot(e, n, _) => { e.ast_debug(w); w.write(format!(".{}", n)) } diff --git a/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs b/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs index 67941b70234bf..581c4c2901ad8 100644 --- a/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs +++ b/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs @@ -401,7 +401,7 @@ fn exp(context: &mut Context, sp!(_, e_): &mut N::Exp) { exp(context, e) } } - N::Exp_::MethodCall(ed, _, _, _, sp!(_, es)) => { + N::Exp_::MethodCall(ed, _, _, _, sp!(_, es), _) => { exp_dotted(context, ed); for e in es { exp(context, e) @@ -416,7 +416,7 @@ fn exp(context: &mut Context, sp!(_, e_): &mut N::Exp) { fn exp_dotted(context: &mut Context, sp!(_, ed_): &mut N::ExpDotted) { match ed_ { N::ExpDotted_::Exp(e) => exp(context, e), - N::ExpDotted_::Dot(ed, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { + N::ExpDotted_::Dot(ed, _, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { exp_dotted(context, ed) } N::ExpDotted_::Index(ed, sp!(_, es)) => { diff --git a/external-crates/move/crates/move-compiler/src/naming/translate.rs b/external-crates/move/crates/move-compiler/src/naming/translate.rs index 905132032466f..4185d6855b756 100644 --- a/external-crates/move/crates/move-compiler/src/naming/translate.rs +++ b/external-crates/move/crates/move-compiler/src/naming/translate.rs @@ -2901,7 +2901,7 @@ fn exp(context: &mut Context, e: Box) -> Box { EE::Call(ma, is_macro, tys_opt, rhs) => { resolve_call(context, eloc, ma, is_macro, tys_opt, rhs) } - EE::MethodCall(edot, n, is_macro, tys_opt, rhs) => match dotted(context, *edot) { + EE::MethodCall(edot, n, is_macro, tys_opt, rhs, dot_loc) => match dotted(context, *edot) { None => { assert!(context.env.has_errors()); NE::UnresolvedError @@ -2912,7 +2912,7 @@ fn exp(context: &mut Context, e: Box) -> Box { if is_macro.is_some() { context.check_feature(context.current_package, FeatureGate::MacroFuns, eloc); } - NE::MethodCall(d, n, is_macro, ty_args, nes) + NE::MethodCall(d, n, is_macro, ty_args, nes, dot_loc) } }, EE::Vector(vec_loc, tys_opt, rhs) => { @@ -2978,7 +2978,9 @@ fn dotted(context: &mut Context, edot: E::ExpDotted) -> Option { _ => N::ExpDotted_::Exp(ne), } } - E::ExpDotted_::Dot(d, f) => N::ExpDotted_::Dot(Box::new(dotted(context, *d)?), Field(f)), + E::ExpDotted_::Dot(d, f, loc) => { + N::ExpDotted_::Dot(Box::new(dotted(context, *d)?), Field(f), loc) + } E::ExpDotted_::DotUnresolved(loc, d) => { N::ExpDotted_::DotAutocomplete(loc, Box::new(dotted(context, *d)?)) } @@ -4328,7 +4330,7 @@ fn remove_unused_bindings_exp( remove_unused_bindings_exp(context, used, e) } } - N::Exp_::MethodCall(ed, _, _, _, sp!(_, es)) => { + N::Exp_::MethodCall(ed, _, _, _, sp!(_, es), _) => { remove_unused_bindings_exp_dotted(context, used, ed); for e in es { remove_unused_bindings_exp(context, used, e) @@ -4346,7 +4348,7 @@ fn remove_unused_bindings_exp_dotted( ) { match ed_ { N::ExpDotted_::Exp(e) => remove_unused_bindings_exp(context, used, e), - N::ExpDotted_::Dot(ed, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { + N::ExpDotted_::Dot(ed, _, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { remove_unused_bindings_exp_dotted(context, used, ed) } N::ExpDotted_::Index(ed, sp!(_, es)) => { diff --git a/external-crates/move/crates/move-compiler/src/parser/ast.rs b/external-crates/move/crates/move-compiler/src/parser/ast.rs index c04017cab5d6b..47516af7e299c 100644 --- a/external-crates/move/crates/move-compiler/src/parser/ast.rs +++ b/external-crates/move/crates/move-compiler/src/parser/ast.rs @@ -628,8 +628,8 @@ pub enum Exp_ { // &mut e Borrow(bool, Box), - // e.f - Dot(Box, Name), + // e.f (along with the location of the dot) + Dot(Box, Name, Loc), // e.f(earg,*) DotCall( Box, @@ -637,6 +637,7 @@ pub enum Exp_ { /* is_macro */ Option, Option>, Spanned>, + Loc, // location of the dot ), // e[e'] Index(Box, Spanned>), // spec only @@ -2128,11 +2129,11 @@ impl AstDebug for Exp_ { } e.ast_debug(w); } - E::Dot(e, n) => { + E::Dot(e, n, _) => { e.ast_debug(w); w.write(format!(".{}", n)); } - E::DotCall(e, n, is_macro, tyargs, sp!(_, rhs)) => { + E::DotCall(e, n, is_macro, tyargs, sp!(_, rhs), _) => { e.ast_debug(w); w.write(format!(".{}", n)); if is_macro.is_some() { diff --git a/external-crates/move/crates/move-compiler/src/parser/syntax.rs b/external-crates/move/crates/move-compiler/src/parser/syntax.rs index ca99059d14a26..499f4e9cde942 100644 --- a/external-crates/move/crates/move-compiler/src/parser/syntax.rs +++ b/external-crates/move/crates/move-compiler/src/parser/syntax.rs @@ -2618,7 +2618,7 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result { let field_access = Name::new(loc, format!("{parsed}").into()); - Exp_::Dot(Box::new(lhs), field_access) + Exp_::Dot(Box::new(lhs), field_access, first_token_loc) } Ok((_, NumberFormat::Hex)) => { let msg = "Invalid field access. Expected a decimal number but was given a hexadecimal"; @@ -2627,7 +2627,7 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result { let msg = format!( @@ -2639,7 +2639,7 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result Result { + N::Exp_::MethodCall(ed, _, _, _, sp!(_, es), _) => { recolor_exp_dotted(ctx, ed); for e in es { recolor_exp(ctx, e) @@ -680,7 +680,7 @@ fn recolor_exp(ctx: &mut Recolor, sp!(_, e_): &mut N::Exp) { fn recolor_exp_dotted(ctx: &mut Recolor, sp!(_, ed_): &mut N::ExpDotted) { match ed_ { N::ExpDotted_::Exp(e) => recolor_exp(ctx, e), - N::ExpDotted_::Dot(ed, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { + N::ExpDotted_::Dot(ed, _, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { recolor_exp_dotted(ctx, ed) } N::ExpDotted_::Index(ed, sp!(_, es)) => { @@ -941,7 +941,7 @@ fn exp(context: &mut Context, sp!(eloc, e_): &mut N::Exp) { } exps(context, es) } - N::Exp_::MethodCall(ed, _, _, tys_opt, sp!(_, es)) => { + N::Exp_::MethodCall(ed, _, _, tys_opt, sp!(_, es), _) => { if let Some(tys) = tys_opt { types(context, tys) } @@ -1158,7 +1158,7 @@ fn builtin_function(context: &mut Context, sp!(_, bf_): &mut N::BuiltinFunction) fn exp_dotted(context: &mut Context, sp!(_, ed_): &mut N::ExpDotted) { match ed_ { N::ExpDotted_::Exp(e) => exp(context, e), - N::ExpDotted_::Dot(ed, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { + N::ExpDotted_::Dot(ed, _, _) | N::ExpDotted_::DotAutocomplete(_, ed) => { exp_dotted(context, ed) } N::ExpDotted_::Index(ed, sp!(_, es)) => { diff --git a/external-crates/move/crates/move-compiler/src/typing/translate.rs b/external-crates/move/crates/move-compiler/src/typing/translate.rs index 496a9483dda54..888ce0d814f4d 100644 --- a/external-crates/move/crates/move-compiler/src/typing/translate.rs +++ b/external-crates/move/crates/move-compiler/src/typing/translate.rs @@ -1503,10 +1503,26 @@ fn exp(context: &mut Context, ne: Box) -> Box { let ty = context.get_local_type(&var); (ty, TE::Use(var)) } - NE::MethodCall(ndotted, f, /* is_macro */ None, ty_args_opt, sp!(argloc, nargs_)) => { + NE::MethodCall( + ndotted, + f, + /* is_macro */ None, + ty_args_opt, + sp!(argloc, nargs_), + dot_loc, + ) => { let edotted = process_exp_dotted(context, None, ndotted); let args = exp_vec(context, nargs_); - let ty_call_opt = method_call(context, eloc, edotted, f, ty_args_opt, argloc, args); + let ty_call_opt = method_call( + context, + eloc, + edotted, + f, + ty_args_opt, + argloc, + args, + dot_loc, + ); match ty_call_opt { None => { assert!(context.env.has_errors()); @@ -1519,7 +1535,14 @@ fn exp(context: &mut Context, ne: Box) -> Box { let args = exp_vec(context, nargs_); module_call(context, eloc, m, f, ty_args_opt, argloc, args) } - NE::MethodCall(ndotted, f, Some(macro_call_loc), ty_args_opt, sp!(argloc, nargs_)) => { + NE::MethodCall( + ndotted, + f, + Some(macro_call_loc), + ty_args_opt, + sp!(argloc, nargs_), + dot_loc, + ) => { let edotted = process_exp_dotted(context, None, ndotted); let ty_call_opt = macro_method_call( context, @@ -1530,6 +1553,7 @@ fn exp(context: &mut Context, ne: Box) -> Box { ty_args_opt, argloc, nargs_, + dot_loc, ); match ty_call_opt { None => { @@ -3054,7 +3078,11 @@ fn resolve_index_funs_and_type( #[derive(Debug)] enum ExpDottedAccess { - Field(Field, /* base type */ Type), + Field( + Field, + /* base type */ Type, + /* dot location */ Loc, + ), Index { index_loc: Loc, syntax_methods: Option, @@ -3090,7 +3118,7 @@ impl ExpDotted { fn last_type(&self) -> Type { if let Some(accessor) = self.accessors.last() { match accessor { - ExpDottedAccess::Field(_, ty) => ty.clone(), + ExpDottedAccess::Field(_, ty, _) => ty.clone(), ExpDottedAccess::Index { base_type, .. } => base_type.clone(), } } else { @@ -3183,7 +3211,7 @@ fn process_exp_dotted( ) -> ExpDotted { match ndot_ { N::ExpDotted_::Exp(e) => process_base_exp(context, constraint_verb, dloc, e), - N::ExpDotted_::Dot(ndot, field) => { + N::ExpDotted_::Dot(ndot, field, dot_loc) => { let mut inner = process_exp_dotted_inner(context, Some("dot access"), *ndot); assert!(inner.autocomplete_last.is_none()); let inner_ty = inner.last_type(); @@ -3191,7 +3219,7 @@ fn process_exp_dotted( inner.loc = dloc; inner .accessors - .push(ExpDottedAccess::Field(field, field_type)); + .push(ExpDottedAccess::Field(field, field_type, dot_loc)); inner } N::ExpDotted_::Index(ndot, sp!(argloc, nargs_)) => { @@ -3229,14 +3257,14 @@ fn exp_dotted_usage( let constraint_verb = match &ndotted.value { N::ExpDotted_::Exp(_) => None, _ if matches!(usage, DottedUsage::Borrow(_)) => Some("borrow"), - N::ExpDotted_::Dot(_, _) | N::ExpDotted_::DotAutocomplete(_, _) => Some("dot access"), + N::ExpDotted_::Dot(_, _, _) | N::ExpDotted_::DotAutocomplete(_, _) => Some("dot access"), N::ExpDotted_::Index(_, _) => Some("index"), }; let edotted = process_exp_dotted(context, constraint_verb, ndotted); if matches!(usage, DottedUsage::Borrow(_)) && edotted.accessors.is_empty() { context.add_base_type_constraint(exp_loc, "Invalid borrow", edotted.base.ty.clone()); } - resolve_exp_dotted(context, usage, exp_loc, edotted) + resolve_exp_dotted(context, usage, exp_loc, edotted, None) } fn exp_dotted_expression( @@ -3250,7 +3278,7 @@ fn exp_dotted_expression( if matches!(usage, DottedUsage::Borrow(_)) && edotted.accessors.is_empty() { context.add_base_type_constraint(error_loc, "Invalid borrow", edotted.base.ty.clone()); } - resolve_exp_dotted(context, usage, error_loc, edotted) + resolve_exp_dotted(context, usage, error_loc, edotted, None) } // This comment servees to document the function below. Depending on the shape of the dotted @@ -3287,6 +3315,7 @@ fn resolve_exp_dotted( usage: DottedUsage, error_loc: Loc, edotted: ExpDotted, + method_dot_loc: Option, ) -> Box { use T::UnannotatedExp_ as TE; @@ -3296,6 +3325,30 @@ fn resolve_exp_dotted( let edotted_ty = core::unfold_type(&context.subst, edotted.last_type()); let autocomplete_last = edotted.autocomplete_last; + if context.env.ide_mode() { + if let Some(mdot_loc) = method_dot_loc { + ide_report_autocomplete(context, &mdot_loc, &edotted_ty); + } + // generate autocomplete information for all dots in the path + for i in (0..edotted.accessors.len()).rev() { + let accessor = &edotted.accessors[i]; + if let ExpDottedAccess::Field(_, _, dot_loc) = accessor { + let prefix_ty = if i == 0 { + edotted.base_type.clone() + } else { + match &edotted.accessors[i - 1] { + ExpDottedAccess::Field(_, ty, _) => ty.clone(), + ExpDottedAccess::Index { base_type, .. } => base_type.clone(), + } + }; + ide_report_autocomplete( + context, + dot_loc, + &core::unfold_type(&context.subst, prefix_ty), + ); + } + } + } let result = match usage { DottedUsage::Move(loc) => { @@ -3393,7 +3446,7 @@ fn resolve_exp_dotted( if let Some(loc) = autocomplete_last { assert!(context.env.ide_mode()); - debug_print!(context.debug.autocomplete_resolution, ("computing autocomplete" => result; dbg)); + debug_print!(context.debug.autocomplete_resolution, ("computing unresolved dot autocomplete" => result; dbg)); ide_report_autocomplete(context, &loc, &edotted_ty); result } else { @@ -3483,7 +3536,7 @@ fn borrow_exp_dotted( for accessor in accessors { check_mut(context, error_loc, exp.ty.clone(), mut_); match accessor { - ExpDottedAccess::Field(name, ty) => { + ExpDottedAccess::Field(name, ty, _) => { // report autocomplete information for the IDE ide_report_autocomplete(context, &name.loc(), &exp.ty); let e_ = TE::Borrow(mut_, exp, name); @@ -3572,7 +3625,7 @@ fn exp_dotted_to_owned( use T::UnannotatedExp_ as TE; let (access_msg, access_type) = if let Some(accessor) = ed.accessors.last() { match accessor { - ExpDottedAccess::Field(name, ty) => (format!("field '{}'", name), ty.clone()), + ExpDottedAccess::Field(name, ty, _) => (format!("field '{}'", name), ty.clone()), ExpDottedAccess::Index { base_type, .. } => { ("index result".to_string(), base_type.clone()) } @@ -3728,6 +3781,7 @@ fn method_call( ty_args_opt: Option>, argloc: Loc, mut args: Vec, + dot_loc: Loc, ) -> Option<(Type, T::UnannotatedExp_)> { use T::UnannotatedExp_ as TE; let mut edotted = edotted; @@ -3738,8 +3792,13 @@ fn method_call( // Even if the method name fails to resolve, we want autocomplete information. edotted.autocomplete_last = Some(method.loc); let err_ty = context.error_type(call_loc); - let dot_output = - resolve_exp_dotted(context, DottedUsage::Borrow(false), call_loc, edotted); + let dot_output = resolve_exp_dotted( + context, + DottedUsage::Borrow(false), + call_loc, + edotted, + Some(dot_loc), + ); return Some((err_ty, dot_output.exp.value)); } ResolvedMethodCall::InvalidBaseType | ResolvedMethodCall::UnknownName => return None, @@ -3748,7 +3807,7 @@ fn method_call( if context.env.ide_mode() { edotted.autocomplete_last = Some(method.loc); } - let first_arg = *resolve_exp_dotted(context, usage, call_loc, edotted); + let first_arg = *resolve_exp_dotted(context, usage, call_loc, edotted, Some(dot_loc)); args.insert(0, first_arg); let (mut call, ret_ty) = module_call_impl(context, call_loc, m, f, fty, argloc, args); call.method_name = Some(method); @@ -4243,6 +4302,7 @@ fn macro_method_call( ty_args_opt: Option>, argloc: Loc, nargs: Vec, + dot_loc: Loc, ) -> Option<(Type, T::UnannotatedExp_)> { let mut edotted = edotted; let (m, f, fty, usage) = match method_call_resolve(context, loc, &edotted, method, ty_args_opt) @@ -4252,7 +4312,13 @@ fn macro_method_call( // Even if the method name fails to resolve, we want autocomplete information. edotted.autocomplete_last = Some(method.loc); let err_ty = context.error_type(loc); - let dot_output = resolve_exp_dotted(context, DottedUsage::Borrow(false), loc, edotted); + let dot_output = resolve_exp_dotted( + context, + DottedUsage::Borrow(false), + loc, + edotted, + Some(dot_loc), + ); return Some((err_ty, dot_output.exp.value)); } ResolvedMethodCall::InvalidBaseType | ResolvedMethodCall::UnknownName => return None, @@ -4261,7 +4327,7 @@ fn macro_method_call( if context.env.ide_mode() { edotted.autocomplete_last = Some(method.loc); } - let first_arg = *resolve_exp_dotted(context, usage, loc, edotted); + let first_arg = *resolve_exp_dotted(context, usage, loc, edotted, Some(dot_loc)); let mut args = vec![macro_expand::EvalStrategy::ByValue(first_arg)]; args.extend( nargs diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/dot_incomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/dot_incomplete.ide.exp index 56ddd626b81cc..98607313517bd 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/dot_incomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/dot_incomplete.ide.exp @@ -13,6 +13,12 @@ error[E01002]: unexpected token │ Unexpected ';' │ Expected an identifier or a decimal number +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/dot_incomplete.move:15:23 + │ +15 │ let _tmp2 = _s.a.; // incomplete with `;` (next line should parse) + │ ^ Possible dot names: 'a' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/dot_incomplete.move:15:24 │ @@ -34,6 +40,12 @@ error[E01002]: unexpected token │ Unexpected ';' │ Expected an identifier or a decimal number +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/dot_incomplete.move:16:23 + │ +16 │ let _tmp3 = _s.a. // incomplete without `;` (unexpected `let`) + │ ^ Possible dot names: 'a' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/dot_incomplete.move:16:24 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_and_field_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_and_field_autocomplete.ide.exp index 6f487bfc65053..e7a86a0d5db49 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_and_field_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_and_field_autocomplete.ide.exp @@ -6,54 +6,108 @@ warning[W09009]: unused struct field │ = This warning can be suppressed with '#[allow(unused_field)]' applied to the 'module' or module member ('const', 'fun', or 'struct') +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:16:20 + │ +16 │ let _ = &in.0.0; + │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:16:21 │ 16 │ let _ = &in.0.0; │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:16:22 + │ +16 │ let _ = &in.0.0; + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:16:23 │ 16 │ let _ = &in.0.0; │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:20:20 + │ +20 │ let _ = &in.0.0.0 ; + │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:20:21 │ 20 │ let _ = &in.0.0.0 ; │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:20:22 + │ +20 │ let _ = &in.0.0.0 ; + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:20:23 │ 20 │ let _ = &in.0.0.0 ; │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:20:24 + │ +20 │ let _ = &in.0.0.0 ; + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:20:25 │ 20 │ let _ = &in.0.0.0 ; │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:20 + │ +24 │ let _ = &in.0.0.0.d ; + │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:21 │ 24 │ let _ = &in.0.0.0.d ; │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:22 + │ +24 │ let _ = &in.0.0.0.d ; + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:23 │ 24 │ let _ = &in.0.0.0.d ; │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:24 + │ +24 │ let _ = &in.0.0.0.d ; + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:25 │ 24 │ let _ = &in.0.0.0.d ; │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:26 + │ +24 │ let _ = &in.0.0.0.d ; + │ ^ Possible dot names: 'a::m::for_c_0', 'a::m::for_c_1', 'c', or 'd' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_and_field_autocomplete.move:24:27 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_autocomplete.ide.exp index b8ffa86589335..7e4a864e94f71 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/method_autocomplete.ide.exp @@ -14,42 +14,84 @@ warning[W09009]: unused struct field │ = This warning can be suppressed with '#[allow(unused_field)]' applied to the 'module' or module member ('const', 'fun', or 'struct') +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:16:11 + │ +16 │ in.for_b_0() + │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:16:12 │ 16 │ in.for_b_0() │ ^^^^^^^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:20:11 + │ +20 │ in.0.for_a_0(); + │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:20:12 │ 20 │ in.0.for_a_0(); │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:20:13 + │ +20 │ in.0.for_a_0(); + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:20:14 │ 20 │ in.0.for_a_0(); │ ^^^^^^^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:11 + │ +24 │ in.0.0.0.for_c_0(); + │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:12 │ 24 │ in.0.0.0.for_c_0(); │ ^ Possible dot names: 'a::m::for_b_0', 'a::m::for_b_1', 'a::m::test0', 'a::m::test1', 'a::m::test2', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:13 + │ +24 │ in.0.0.0.for_c_0(); + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:14 │ 24 │ in.0.0.0.for_c_0(); │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:15 + │ +24 │ in.0.0.0.for_c_0(); + │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:16 │ 24 │ in.0.0.0.for_c_0(); │ ^ Possible dot names: 'a::m::for_a_0', 'a::m::for_a_1', or '0' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:17 + │ +24 │ in.0.0.0.for_c_0(); + │ ^ Possible dot names: 'a::m::for_c_0', 'a::m::for_c_1', 'c', or 'd' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/method_autocomplete.move:24:18 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_autocomplete.ide.exp index 32142840025e1..53e71a6b31f48 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_autocomplete.ide.exp @@ -13,6 +13,12 @@ error[E01002]: unexpected token │ Unexpected ';' │ Expected an identifier or a decimal number +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/named_struct_autocomplete.move:15:23 + │ +15 │ let _tmp2 = _s.a.; + │ ^ Possible dot names: 'a' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/named_struct_autocomplete.move:15:24 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_middle_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_middle_autocomplete.ide.exp index 9efccbe1276d3..04484c1f18103 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_middle_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/named_struct_middle_autocomplete.ide.exp @@ -4,6 +4,12 @@ error[E03010]: unbound field 14 │ let _tmp2 = _s.b.x; │ ^^^^ Unbound field 'b' in 'a::m::B' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/named_struct_middle_autocomplete.move:14:23 + │ +14 │ let _tmp2 = _s.b.x; + │ ^ Possible dot names: 'a' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/named_struct_middle_autocomplete.move:14:24 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/positional_struct_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/positional_struct_autocomplete.ide.exp index 9a0b8f3f40634..0c449a5f66c08 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/positional_struct_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/positional_struct_autocomplete.ide.exp @@ -13,6 +13,12 @@ error[E01002]: unexpected token │ Unexpected ';' │ Expected an identifier or a decimal number +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/positional_struct_autocomplete.move:11:23 + │ +11 │ let _tmp2 = _s.0.; + │ ^ Possible dot names: '0' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/positional_struct_autocomplete.move:11:24 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/struct_method_invalid_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/struct_method_invalid_autocomplete.ide.exp index ad1bed3a378bb..4e1ddff4ae4d1 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/struct_method_invalid_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/struct_method_invalid_autocomplete.ide.exp @@ -7,6 +7,12 @@ error[E04023]: invalid method call │ │ No local 'use fun' alias was found for 'a::m::A.t7', and no function 't7' was found in the defining module 'a::m' │ Invalid method call. No known method 't7' on type 'a::m::A' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/struct_method_invalid_autocomplete.move:20:23 + │ +20 │ let _tmp1 = _a.t7(); + │ ^ Possible dot names: 'a::m::t0', 'a::m::t1', or 'a::m::t2' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/struct_method_invalid_autocomplete.move:20:24 │ @@ -22,6 +28,12 @@ error[E04023]: invalid method call │ │ No local 'use fun' alias was found for 'a::m::B.t8', and no function 't8' was found in the defining module 'a::m' │ Invalid method call. No known method 't8' on type 'a::m::B' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/struct_method_invalid_autocomplete.move:21:23 + │ +21 │ let _tmp2 = _b.t8(); + │ ^ Possible dot names: 'a::m::t3', 'a::m::t4', or 'a::m::t5' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/struct_method_invalid_autocomplete.move:21:24 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp index 02aa8a5440eb8..1d08e72f5e14a 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp @@ -78,9 +78,32 @@ error[E04009]: expected specific type 6 │ &mut action.inner.bar │ ^^^^^^^^^^^^^^^^ Unbound field 'bar' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/type_param_autocomplete.move:6:16 + │ +6 │ &mut action.inner.bar + │ ^ Possible dot names: '0x42::m::make_action_ref' or 'inner' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/type_param_autocomplete.move:6:17 │ 6 │ &mut action.inner.bar │ ^^^^^ Possible dot names: '0x42::m::make_action_ref' or 'inner' +error[E04023]: invalid method call + ┌─ tests/move_2024/ide_mode/type_param_autocomplete.move:6:22 + │ +5 │ public fun make_action_ref(action: &mut Action): &mut T { + │ - Autocompletions are not supported on type parameters. Got an expression of type: 'T' +6 │ &mut action.inner.bar + │ ^ Invalid autocompletion + +error[E04023]: invalid method call + ┌─ tests/move_2024/ide_mode/type_param_autocomplete.move:6:23 + │ +6 │ &mut action.inner.bar + │ -------------^^^ + │ │ │ + │ │ Invalid autocompletion + │ Autocompletions are not supported on type parameters. Got an expression of type: 'T' + diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_no_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_no_autocomplete.ide.exp index f5979220c25c8..ed441c4c9c0f3 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_no_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_no_autocomplete.ide.exp @@ -70,6 +70,12 @@ note[I15006]: IDE path autocomplete = addresses: 'A -> 0x41', 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' = type params: 'T' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/type_param_no_autocomplete.move:6:16 + │ +6 │ &mut action.inner + │ ^ Possible dot names: '0x42::m::make_action_ref' or 'inner' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/type_param_no_autocomplete.move:6:17 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/use_fun_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/use_fun_autocomplete.ide.exp index 3d2a42795af61..7fa6e5ced59a7 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/use_fun_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/use_fun_autocomplete.ide.exp @@ -1,9 +1,21 @@ +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/use_fun_autocomplete.move:12:10 + │ +12 │ s.bak(); // autocompletion to `bak` and `foo` + │ ^ Possible dot names: '0x42::m1::bak', '0x42::m1::foo', '0x42::m1::test1', or '0x42::m1::test2' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/use_fun_autocomplete.move:12:11 │ 12 │ s.bak(); // autocompletion to `bak` and `foo` │ ^^^ Possible dot names: '0x42::m1::bak', '0x42::m1::foo', '0x42::m1::test1', or '0x42::m1::test2' +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/use_fun_autocomplete.move:17:10 + │ +17 │ s.bar(); // auto-completion to only one (shadowed) `bar` + │ ^ Possible dot names: '0x42::m1::bar', '0x42::m1::test1', or '0x42::m1::test2' + note[I15001]: IDE dot autocomplete ┌─ tests/move_2024/ide_mode/use_fun_autocomplete.move:17:11 │ diff --git a/external-crates/move/crates/move-compiler/tests/move_check/ide_mode/named_struct_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_check/ide_mode/named_struct_autocomplete.ide.exp index 2ef5a7c61e2a6..71fb04dbe0674 100644 --- a/external-crates/move/crates/move-compiler/tests/move_check/ide_mode/named_struct_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_check/ide_mode/named_struct_autocomplete.ide.exp @@ -96,6 +96,12 @@ note[I15006]: IDE path autocomplete = addresses: 'A -> 0x41', 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' = type params: +note[I15001]: IDE dot autocomplete + ┌─ tests/move_check/ide_mode/named_struct_autocomplete.move:14:23 + │ +14 │ let _tmp2 = _s.a.; + │ ^ Possible dot names: 'a' + note[I15001]: IDE dot autocomplete ┌─ tests/move_check/ide_mode/named_struct_autocomplete.move:14:24 │ From 1bfcd63f10bc4ed8bf5fb7722159cd13b06305e9 Mon Sep 17 00:00:00 2001 From: Adam Welc Date: Mon, 4 Nov 2024 17:05:01 -0800 Subject: [PATCH 2/4] Added a test --- .../ide_mode/on_dot_autocomplete.exp | 15 +++ .../ide_mode/on_dot_autocomplete.ide | 0 .../ide_mode/on_dot_autocomplete.ide.exp | 105 ++++++++++++++++++ .../ide_mode/on_dot_autocomplete.move | 25 +++++ 4 files changed, 145 insertions(+) create mode 100644 external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.exp create mode 100644 external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide create mode 100644 external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide.exp create mode 100644 external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.move diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.exp new file mode 100644 index 0000000000000..d7a3330d71221 --- /dev/null +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.exp @@ -0,0 +1,15 @@ +warning[W10007]: issue with attribute value + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:1:9 + │ +1 │ #[allow(ide_path_autocomplete)] + │ ^^^^^^^^^^^^^^^^^^^^^ Unknown warning filter 'ide_path_autocomplete' + +error[E04023]: invalid method call + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:9 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^^^^^^^^^ + │ │ │ + │ │ No local 'use fun' alias was found for 'a::m::A.b', and no function 'b' was found in the defining module 'a::m' + │ Invalid method call. No known method 'b' on type 'a::m::A' + diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide.exp new file mode 100644 index 0000000000000..928a987e3a999 --- /dev/null +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.ide.exp @@ -0,0 +1,105 @@ +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:21:10 + │ +21 │ c.b.a; // two dots that should trigger auto-completion + │ ^ Possible dot names: 'b' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:21:11 + │ +21 │ c.b.a; // two dots that should trigger auto-completion + │ ^ Possible dot names: 'b' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:21:12 + │ +21 │ c.b.a; // two dots that should trigger auto-completion + │ ^ Possible dot names: 'a' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:21:13 + │ +21 │ c.b.a; // two dots that should trigger auto-completion + │ ^ Possible dot names: 'a' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:22:10 + │ +22 │ c.b.a.bar(); // resolved method name + │ ^ Possible dot names: 'b' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:22:11 + │ +22 │ c.b.a.bar(); // resolved method name + │ ^ Possible dot names: 'b' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:22:12 + │ +22 │ c.b.a.bar(); // resolved method name + │ ^ Possible dot names: 'a' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:22:13 + │ +22 │ c.b.a.bar(); // resolved method name + │ ^ Possible dot names: 'a' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:22:14 + │ +22 │ c.b.a.bar(); // resolved method name + │ ^ Possible dot names: 'a::m::bar' or 'x' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:22:15 + │ +22 │ c.b.a.bar(); // resolved method name + │ ^^^ Possible dot names: 'a::m::bar' or 'x' + +error[E04023]: invalid method call + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:9 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^^^^^^^^^ + │ │ │ + │ │ No local 'use fun' alias was found for 'a::m::A.b', and no function 'b' was found in the defining module 'a::m' + │ Invalid method call. No known method 'b' on type 'a::m::A' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:10 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^ Possible dot names: 'b' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:11 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^ Possible dot names: 'b' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:12 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^ Possible dot names: 'a' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:13 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^ Possible dot names: 'a' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:14 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^ Possible dot names: 'a::m::bar' or 'x' + +note[I15001]: IDE dot autocomplete + ┌─ tests/move_2024/ide_mode/on_dot_autocomplete.move:23:15 + │ +23 │ c.b.a.b(); // unresolved method name + │ ^ Possible dot names: 'a::m::bar' or 'x' + diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.move b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.move new file mode 100644 index 0000000000000..f6c41714cf093 --- /dev/null +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/on_dot_autocomplete.move @@ -0,0 +1,25 @@ +#[allow(ide_path_autocomplete)] +module a::m { + + public struct A has copy, drop { + x: u64 + } + + public struct B has copy, drop { + a: A + } + + public struct C has copy, drop { + b: B + } + + public fun bar(_a: A) {} + + public fun foo() { + let b = B { a: A { x: 0 } }; + let c = C { b: b }; + c.b.a; // two dots that should trigger auto-completion + c.b.a.bar(); // resolved method name + c.b.a.b(); // unresolved method name + } +} From d8c1b0cbbcc5b259a9e876316ac088e293111495 Mon Sep 17 00:00:00 2001 From: Adam Welc Date: Tue, 5 Nov 2024 13:50:06 -0800 Subject: [PATCH 3/4] Addressed review comments --- .../src/analysis/parsing_analysis.rs | 2 +- .../crates/move-compiler/src/expansion/ast.rs | 8 ++++---- .../move-compiler/src/expansion/translate.rs | 8 ++++---- .../move/crates/move-compiler/src/naming/ast.rs | 4 ++-- .../move-compiler/src/naming/translate.rs | 6 +++--- .../move/crates/move-compiler/src/parser/ast.rs | 8 ++++---- .../crates/move-compiler/src/parser/syntax.rs | 10 +++++----- .../move-compiler/src/typing/translate.rs | 16 ++++++++-------- .../ide_mode/type_param_autocomplete.ide.exp | 17 ----------------- 9 files changed, 31 insertions(+), 48 deletions(-) diff --git a/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs b/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs index 9eb07f7e35706..e5a11a9c13453 100644 --- a/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs +++ b/external-crates/move/crates/move-analyzer/src/analysis/parsing_analysis.rs @@ -447,7 +447,7 @@ impl<'a> ParsingAnalysisContext<'a> { } E::Borrow(_, e) => self.exp_symbols(e), E::Dot(e, _, _) => self.exp_symbols(e), - E::DotCall(e, name, _, vo, v, _) => { + E::DotCall(e, _, name, _, vo, v) => { self.exp_symbols(e); if let Some(v) = vo { v.iter().for_each(|t| self.type_symbols(t)); diff --git a/external-crates/move/crates/move-compiler/src/expansion/ast.rs b/external-crates/move/crates/move-compiler/src/expansion/ast.rs index 78cd54352193e..d1cf6d6f4b495 100644 --- a/external-crates/move/crates/move-compiler/src/expansion/ast.rs +++ b/external-crates/move/crates/move-compiler/src/expansion/ast.rs @@ -336,7 +336,7 @@ pub type LambdaLValues = Spanned; #[allow(clippy::large_enum_variant)] pub enum ExpDotted_ { Exp(Box), - Dot(Box, Name, Loc), + Dot(Box, /* dot location */ Loc, Name), Index(Box, Spanned>), DotUnresolved(Loc, Box), // dot where Name could not be parsed } @@ -389,11 +389,11 @@ pub enum Exp_ { ), MethodCall( Box, + Loc, // location of the dot Name, /* is_macro */ Option, Option>, Spanned>, - Loc, // location of the dot ), Pack(ModuleAccess, Option>, Fields), Vector(Loc, Option>, Spanned>), @@ -1531,7 +1531,7 @@ impl AstDebug for Exp_ { w.comma(rhs, |w, e| e.ast_debug(w)); w.write(")"); } - E::MethodCall(e, f, is_macro, tys_opt, sp!(_, rhs), _) => { + E::MethodCall(e, _, f, is_macro, tys_opt, sp!(_, rhs)) => { e.ast_debug(w); w.write(format!(".{}", f)); if is_macro.is_some() { @@ -1731,7 +1731,7 @@ impl AstDebug for ExpDotted_ { use ExpDotted_ as D; match self { D::Exp(e) => e.ast_debug(w), - D::Dot(e, n, _) => { + D::Dot(e, _, n) => { e.ast_debug(w); w.write(format!(".{}", n)) } diff --git a/external-crates/move/crates/move-compiler/src/expansion/translate.rs b/external-crates/move/crates/move-compiler/src/expansion/translate.rs index 2946a425a61ca..7cfed57692b9f 100644 --- a/external-crates/move/crates/move-compiler/src/expansion/translate.rs +++ b/external-crates/move/crates/move-compiler/src/expansion/translate.rs @@ -2728,14 +2728,14 @@ fn exp(context: &mut Context, pe: Box) -> Box { } } - PE::DotCall(pdotted, n, is_macro, ptys_opt, sp!(rloc, prs), dot_loc) => { + PE::DotCall(pdotted, dot_loc, n, is_macro, ptys_opt, sp!(rloc, prs)) => { match exp_dotted(context, pdotted) { Some(edotted) => { let pkg = context.current_package(); context.check_feature(pkg, FeatureGate::DotCall, loc); let tys_opt = optional_types(context, ptys_opt); let ers = sp(rloc, exps(context, prs)); - EE::MethodCall(edotted, n, is_macro, tys_opt, ers, dot_loc) + EE::MethodCall(edotted, dot_loc, n, is_macro, tys_opt, ers) } None => { assert!(context.env().has_errors()); @@ -2922,9 +2922,9 @@ fn exp_dotted(context: &mut Context, pdotted: Box) -> Option { + PE::Dot(plhs, dot_loc, field) => { let lhs = exp_dotted(context, plhs)?; - EE::Dot(lhs, field, dot_loc) + EE::Dot(lhs, dot_loc, field) } PE::Index(plhs, sp!(argloc, args)) => { let cur_pkg = context.current_package(); diff --git a/external-crates/move/crates/move-compiler/src/naming/ast.rs b/external-crates/move/crates/move-compiler/src/naming/ast.rs index 6acb258426a0b..042605ed2fa07 100644 --- a/external-crates/move/crates/move-compiler/src/naming/ast.rs +++ b/external-crates/move/crates/move-compiler/src/naming/ast.rs @@ -358,7 +358,7 @@ pub type LambdaLValues = Spanned; #[derive(Debug, PartialEq, Clone)] pub enum ExpDotted_ { Exp(Box), - Dot(Box, Field, Loc), + Dot(Box, /* dot loation */ Loc, Field), Index(Box, Spanned>), DotAutocomplete(Loc, Box), // Dot (and its location) where Field could not be parsed } @@ -1890,7 +1890,7 @@ impl AstDebug for ExpDotted_ { use ExpDotted_ as D; match self { D::Exp(e) => e.ast_debug(w), - D::Dot(e, n, _) => { + D::Dot(e, _, n) => { e.ast_debug(w); w.write(format!(".{}", n)) } diff --git a/external-crates/move/crates/move-compiler/src/naming/translate.rs b/external-crates/move/crates/move-compiler/src/naming/translate.rs index 4185d6855b756..af3315a50f523 100644 --- a/external-crates/move/crates/move-compiler/src/naming/translate.rs +++ b/external-crates/move/crates/move-compiler/src/naming/translate.rs @@ -2901,7 +2901,7 @@ fn exp(context: &mut Context, e: Box) -> Box { EE::Call(ma, is_macro, tys_opt, rhs) => { resolve_call(context, eloc, ma, is_macro, tys_opt, rhs) } - EE::MethodCall(edot, n, is_macro, tys_opt, rhs, dot_loc) => match dotted(context, *edot) { + EE::MethodCall(edot, dot_loc, n, is_macro, tys_opt, rhs) => match dotted(context, *edot) { None => { assert!(context.env.has_errors()); NE::UnresolvedError @@ -2978,8 +2978,8 @@ fn dotted(context: &mut Context, edot: E::ExpDotted) -> Option { _ => N::ExpDotted_::Exp(ne), } } - E::ExpDotted_::Dot(d, f, loc) => { - N::ExpDotted_::Dot(Box::new(dotted(context, *d)?), Field(f), loc) + E::ExpDotted_::Dot(d, loc, f) => { + N::ExpDotted_::Dot(Box::new(dotted(context, *d)?), loc, Field(f)) } E::ExpDotted_::DotUnresolved(loc, d) => { N::ExpDotted_::DotAutocomplete(loc, Box::new(dotted(context, *d)?)) diff --git a/external-crates/move/crates/move-compiler/src/parser/ast.rs b/external-crates/move/crates/move-compiler/src/parser/ast.rs index 47516af7e299c..79a09c13a0410 100644 --- a/external-crates/move/crates/move-compiler/src/parser/ast.rs +++ b/external-crates/move/crates/move-compiler/src/parser/ast.rs @@ -629,15 +629,15 @@ pub enum Exp_ { Borrow(bool, Box), // e.f (along with the location of the dot) - Dot(Box, Name, Loc), + Dot(Box, /* dot location */ Loc, Name), // e.f(earg,*) DotCall( Box, + Loc, // location of the dot Name, /* is_macro */ Option, Option>, Spanned>, - Loc, // location of the dot ), // e[e'] Index(Box, Spanned>), // spec only @@ -2129,11 +2129,11 @@ impl AstDebug for Exp_ { } e.ast_debug(w); } - E::Dot(e, n, _) => { + E::Dot(e, _, n) => { e.ast_debug(w); w.write(format!(".{}", n)); } - E::DotCall(e, n, is_macro, tyargs, sp!(_, rhs), _) => { + E::DotCall(e, _, n, is_macro, tyargs, sp!(_, rhs)) => { e.ast_debug(w); w.write(format!(".{}", n)); if is_macro.is_some() { diff --git a/external-crates/move/crates/move-compiler/src/parser/syntax.rs b/external-crates/move/crates/move-compiler/src/parser/syntax.rs index 499f4e9cde942..c8eb34a7722ac 100644 --- a/external-crates/move/crates/move-compiler/src/parser/syntax.rs +++ b/external-crates/move/crates/move-compiler/src/parser/syntax.rs @@ -2618,7 +2618,7 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result { let field_access = Name::new(loc, format!("{parsed}").into()); - Exp_::Dot(Box::new(lhs), field_access, first_token_loc) + Exp_::Dot(Box::new(lhs), first_token_loc, field_access) } Ok((_, NumberFormat::Hex)) => { let msg = "Invalid field access. Expected a decimal number but was given a hexadecimal"; @@ -2627,7 +2627,7 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result { let msg = format!( @@ -2639,7 +2639,7 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result Result Type { if let Some(accessor) = self.accessors.last() { match accessor { - ExpDottedAccess::Field(_, ty, _) => ty.clone(), + ExpDottedAccess::Field(_, _, ty) => ty.clone(), ExpDottedAccess::Index { base_type, .. } => base_type.clone(), } } else { @@ -3211,7 +3211,7 @@ fn process_exp_dotted( ) -> ExpDotted { match ndot_ { N::ExpDotted_::Exp(e) => process_base_exp(context, constraint_verb, dloc, e), - N::ExpDotted_::Dot(ndot, field, dot_loc) => { + N::ExpDotted_::Dot(ndot, dot_loc, field) => { let mut inner = process_exp_dotted_inner(context, Some("dot access"), *ndot); assert!(inner.autocomplete_last.is_none()); let inner_ty = inner.last_type(); @@ -3219,7 +3219,7 @@ fn process_exp_dotted( inner.loc = dloc; inner .accessors - .push(ExpDottedAccess::Field(field, field_type, dot_loc)); + .push(ExpDottedAccess::Field(dot_loc, field, field_type)); inner } N::ExpDotted_::Index(ndot, sp!(argloc, nargs_)) => { @@ -3332,12 +3332,12 @@ fn resolve_exp_dotted( // generate autocomplete information for all dots in the path for i in (0..edotted.accessors.len()).rev() { let accessor = &edotted.accessors[i]; - if let ExpDottedAccess::Field(_, _, dot_loc) = accessor { + if let ExpDottedAccess::Field(dot_loc, _, _) = accessor { let prefix_ty = if i == 0 { edotted.base_type.clone() } else { match &edotted.accessors[i - 1] { - ExpDottedAccess::Field(_, ty, _) => ty.clone(), + ExpDottedAccess::Field(_, _, ty) => ty.clone(), ExpDottedAccess::Index { base_type, .. } => base_type.clone(), } }; @@ -3536,7 +3536,7 @@ fn borrow_exp_dotted( for accessor in accessors { check_mut(context, error_loc, exp.ty.clone(), mut_); match accessor { - ExpDottedAccess::Field(name, ty, _) => { + ExpDottedAccess::Field(_, name, ty) => { // report autocomplete information for the IDE ide_report_autocomplete(context, &name.loc(), &exp.ty); let e_ = TE::Borrow(mut_, exp, name); @@ -3625,7 +3625,7 @@ fn exp_dotted_to_owned( use T::UnannotatedExp_ as TE; let (access_msg, access_type) = if let Some(accessor) = ed.accessors.last() { match accessor { - ExpDottedAccess::Field(name, ty, _) => (format!("field '{}'", name), ty.clone()), + ExpDottedAccess::Field(_, name, ty) => (format!("field '{}'", name), ty.clone()), ExpDottedAccess::Index { base_type, .. } => { ("index result".to_string(), base_type.clone()) } diff --git a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp index 1d08e72f5e14a..cfa978bf4437c 100644 --- a/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp +++ b/external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/type_param_autocomplete.ide.exp @@ -90,20 +90,3 @@ note[I15001]: IDE dot autocomplete 6 │ &mut action.inner.bar │ ^^^^^ Possible dot names: '0x42::m::make_action_ref' or 'inner' -error[E04023]: invalid method call - ┌─ tests/move_2024/ide_mode/type_param_autocomplete.move:6:22 - │ -5 │ public fun make_action_ref(action: &mut Action): &mut T { - │ - Autocompletions are not supported on type parameters. Got an expression of type: 'T' -6 │ &mut action.inner.bar - │ ^ Invalid autocompletion - -error[E04023]: invalid method call - ┌─ tests/move_2024/ide_mode/type_param_autocomplete.move:6:23 - │ -6 │ &mut action.inner.bar - │ -------------^^^ - │ │ │ - │ │ Invalid autocompletion - │ Autocompletions are not supported on type parameters. Got an expression of type: 'T' - From fe8af0b6e1b5a26e15d56e2241d6ea09f1a5cf60 Mon Sep 17 00:00:00 2001 From: Adam Welc Date: Tue, 5 Nov 2024 13:57:08 -0800 Subject: [PATCH 4/4] Continued addressing review comments --- external-crates/move/crates/move-compiler/src/naming/ast.rs | 4 ++-- .../move/crates/move-compiler/src/naming/resolve_use_funs.rs | 2 +- .../move/crates/move-compiler/src/naming/translate.rs | 4 ++-- .../move/crates/move-compiler/src/typing/macro_expand.rs | 4 ++-- .../move/crates/move-compiler/src/typing/translate.rs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/external-crates/move/crates/move-compiler/src/naming/ast.rs b/external-crates/move/crates/move-compiler/src/naming/ast.rs index 042605ed2fa07..e270411ed856d 100644 --- a/external-crates/move/crates/move-compiler/src/naming/ast.rs +++ b/external-crates/move/crates/move-compiler/src/naming/ast.rs @@ -417,11 +417,11 @@ pub enum Exp_ { ), MethodCall( ExpDotted, + Loc, // location of the dot Name, /* is_macro */ Option, Option>, Spanned>, - Loc, // location of the dot ), VarCall(Var, Spanned>), Builtin(BuiltinFunction, Spanned>), @@ -1637,7 +1637,7 @@ impl AstDebug for Exp_ { w.comma(rhs, |w, e| e.ast_debug(w)); w.write(")"); } - E::MethodCall(e, f, is_macro, tys_opt, sp!(_, rhs), _) => { + E::MethodCall(e, _, f, is_macro, tys_opt, sp!(_, rhs)) => { e.ast_debug(w); w.write(format!(".{}", f)); if is_macro.is_some() { diff --git a/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs b/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs index 581c4c2901ad8..778df7cf3f8fb 100644 --- a/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs +++ b/external-crates/move/crates/move-compiler/src/naming/resolve_use_funs.rs @@ -401,7 +401,7 @@ fn exp(context: &mut Context, sp!(_, e_): &mut N::Exp) { exp(context, e) } } - N::Exp_::MethodCall(ed, _, _, _, sp!(_, es), _) => { + N::Exp_::MethodCall(ed, _, _, _, _, sp!(_, es)) => { exp_dotted(context, ed); for e in es { exp(context, e) diff --git a/external-crates/move/crates/move-compiler/src/naming/translate.rs b/external-crates/move/crates/move-compiler/src/naming/translate.rs index af3315a50f523..8b43ff58a0aa9 100644 --- a/external-crates/move/crates/move-compiler/src/naming/translate.rs +++ b/external-crates/move/crates/move-compiler/src/naming/translate.rs @@ -2912,7 +2912,7 @@ fn exp(context: &mut Context, e: Box) -> Box { if is_macro.is_some() { context.check_feature(context.current_package, FeatureGate::MacroFuns, eloc); } - NE::MethodCall(d, n, is_macro, ty_args, nes, dot_loc) + NE::MethodCall(d, dot_loc, n, is_macro, ty_args, nes) } }, EE::Vector(vec_loc, tys_opt, rhs) => { @@ -4330,7 +4330,7 @@ fn remove_unused_bindings_exp( remove_unused_bindings_exp(context, used, e) } } - N::Exp_::MethodCall(ed, _, _, _, sp!(_, es), _) => { + N::Exp_::MethodCall(ed, _, _, _, _, sp!(_, es)) => { remove_unused_bindings_exp_dotted(context, used, ed); for e in es { remove_unused_bindings_exp(context, used, e) diff --git a/external-crates/move/crates/move-compiler/src/typing/macro_expand.rs b/external-crates/move/crates/move-compiler/src/typing/macro_expand.rs index 47a9c5889b8d9..01f56a3724b6f 100644 --- a/external-crates/move/crates/move-compiler/src/typing/macro_expand.rs +++ b/external-crates/move/crates/move-compiler/src/typing/macro_expand.rs @@ -642,7 +642,7 @@ fn recolor_exp(ctx: &mut Recolor, sp!(_, e_): &mut N::Exp) { recolor_exp(ctx, e) } } - N::Exp_::MethodCall(ed, _, _, _, sp!(_, es), _) => { + N::Exp_::MethodCall(ed, _, _, _, _, sp!(_, es)) => { recolor_exp_dotted(ctx, ed); for e in es { recolor_exp(ctx, e) @@ -941,7 +941,7 @@ fn exp(context: &mut Context, sp!(eloc, e_): &mut N::Exp) { } exps(context, es) } - N::Exp_::MethodCall(ed, _, _, tys_opt, sp!(_, es), _) => { + N::Exp_::MethodCall(ed, _, _, _, tys_opt, sp!(_, es)) => { if let Some(tys) = tys_opt { types(context, tys) } diff --git a/external-crates/move/crates/move-compiler/src/typing/translate.rs b/external-crates/move/crates/move-compiler/src/typing/translate.rs index 5282d0f98046d..8e1906b706ed5 100644 --- a/external-crates/move/crates/move-compiler/src/typing/translate.rs +++ b/external-crates/move/crates/move-compiler/src/typing/translate.rs @@ -1505,11 +1505,11 @@ fn exp(context: &mut Context, ne: Box) -> Box { } NE::MethodCall( ndotted, + dot_loc, f, /* is_macro */ None, ty_args_opt, sp!(argloc, nargs_), - dot_loc, ) => { let edotted = process_exp_dotted(context, None, ndotted); let args = exp_vec(context, nargs_); @@ -1537,11 +1537,11 @@ fn exp(context: &mut Context, ne: Box) -> Box { } NE::MethodCall( ndotted, + dot_loc, f, Some(macro_call_loc), ty_args_opt, sp!(argloc, nargs_), - dot_loc, ) => { let edotted = process_exp_dotted(context, None, ndotted); let ty_call_opt = macro_method_call(