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 4 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 5, 2024 9:58pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Nov 5, 2024 9:58pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Nov 5, 2024 9:58pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Nov 5, 2024 9:58pm

@awelc awelc temporarily deployed to sui-typescript-aws-kms-test-env November 5, 2024 01:13 — with GitHub Actions Inactive
@@ -358,7 +358,7 @@ pub type LambdaLValues = Spanned<LambdaLValues_>;
#[derive(Debug, PartialEq, Clone)]
pub enum ExpDotted_ {
Exp(Box<Exp>),
Dot(Box<ExpDotted>, Field),
Copy link
Contributor

@cgswords cgswords Nov 5, 2024

Choose a reason for hiding this comment

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

Nit: Loc should be in the middle, with a comment indicating what the location is

@@ -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

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