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

Add referenced, but not implemented, methods to function autocomplete #2053

Open
mnemnion opened this issue Oct 16, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@mnemnion
Copy link
Contributor

Say I'm working on a function, and realize I'll need another method to finish it:

pub fn doingSomething(self: @This(), param: SomeParameter) void {
     // stuff 
     const return = self.doSomethingNew(value);
}

In my color scheme, doSomethingNew will be white instead of green, because it doesn't exist. Your highlights may vary.

What would be nice is, when I go to implement it, I get a completion:

fn d| // This offers doSomethingNew as a completion

In addition to the convenience, it means I know that the name of the method I'm implementing is the name which I already gave it. Sort of like the very nice feature in switch statements where the completions only contain unreferenced enums, so if you don't get a completion you know you've covered all cases, in this case if there are no completions then I'd know that I don't have any method stubs in the code which need to be written out.

There are some more advanced things which could be done, in terms of filling in the types based on what the prior code passes them, but just the completion would be a great feature.

@mnemnion mnemnion added the enhancement New feature or request label Oct 16, 2024
@Techatrix
Copy link
Member

There could also be a code action that would create the missing function.
Here is an example with typescript-language-server in VS Code:

output.mp4

Implementing this would require more reliable type information.

@mnemnion
Copy link
Contributor Author

That would be a lovely stretch goal, indeed. I can see where the general comptime and return-type-inference challenges with type info would apply there as well.

Even moving whatever information tells the language server that a nonexistent function shouldn't be function-colored, to the declaration-level autocomplete context, would be a solid quality-of-life feature.

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

No branches or pull requests

2 participants