Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[move-ide] Fixed auto-completion on the dot character #20175

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

awelc
Copy link
Contributor

@awelc awelc commented Nov 5, 2024

Description

This PR fixes a certain problem with auto-completion on the . character. Previously, once a part of the access chain after the . was parsed, auto-completion information for the . character location was no longer generated. This is particularly problematic if someone expects auto-completion in the middle of the function code, for example:

public struct SomeStruct has drop {
    some_field: u64,
}

public fun foo(_param: SomeStruct) {}

public fun bar(): SomeStruct {
    let val = SomeStruct{some_field: 42};
    val.
    SomeStruct {some_field: 42}
}

It is expected that auto-completion would work correctly after val. but previously it did not because this expression was actually parsed as val.SomeStruct. This PR fixes this:
image

Previously, auto-completion for the . location would also not work if what follows the . is a function call (whether the function being called was resolved correctly or not). It now works correctly in both cases:
image
image

Test plan

All new and (updated) all tests must pass

@awelc awelc self-assigned this Nov 5, 2024
Copy link

vercel bot commented Nov 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 6:47pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 6:47pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 6:47pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 6:47pm

@awelc awelc temporarily deployed to sui-typescript-aws-kms-test-env November 5, 2024 01:13 — with GitHub Actions Inactive
@@ -393,6 +393,7 @@ pub enum Exp_ {
/* is_macro */ Option<Loc>,
Option<Vec<Type>>,
Spanned<Vec<Exp>>,
Loc, // location of the dot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put Loc between the boxed expression and the name.

@@ -336,7 +336,7 @@ pub type LambdaLValues = Spanned<LambdaLValues_>;
#[allow(clippy::large_enum_variant)]
pub enum ExpDotted_ {
Exp(Box<Exp>),
Dot(Box<ExpDotted>, Name),
Dot(Box<ExpDotted>, Name, Loc),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loc in the middle

Comment on lines +3427 to +3432
if context.env.ide_mode() {
if let Some(mdot_loc) = method_dot_loc {
ide_report_autocomplete(context, &mdot_loc, &edotted_ty);
}
}
result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is redundant.

Suggested change
if context.env.ide_mode() {
if let Some(mdot_loc) = method_dot_loc {
ide_report_autocomplete(context, &mdot_loc, &edotted_ty);
}
}
result
if let Some(mdot_loc) = method_dot_loc {
ide_report_autocomplete(context, &mdot_loc, &edotted_ty);
}
result

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for one tiny nit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants