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

Type-aware completions #317

Open
kubukoz opened this issue Dec 9, 2022 · 1 comment
Open

Type-aware completions #317

kubukoz opened this issue Dec 9, 2022 · 1 comment

Comments

@kubukoz
Copy link

kubukoz commented Dec 9, 2022

Is your feature request related to a problem? Please describe.

When I ask for completions, they don't seem to take into account the expected type at the cursor position. For example:

//> using scala "3.2.1"

case class MyClass(s: String)

def f(x: MyClass) = ()

def main = {
  f(x = @@)
  $$
}

In here, I get the same completions at @@ as I would at $$.

Describe the solution you'd like

At @@, I would like to see something like a call to MyClass(...) as one of the first options, as well as any variables in scope that happen to match that type.

This would be incredibly useful in presence of sealed traits/enums (especially sealed traits whose members aren't contained in the companion object), singleton types and unions (including unions of singletons).

Describe alternatives you've considered

IntelliJ, crying myself to sleep, a combination of the two, manually writing the code

Additional context

Type-aware completions are a well-known feature of other editors like IntelliJ IDEA, as well as something supported in other languages like Typescript in VS Code.

image

IntelliJ is definitely much smarter about this, and I don't think we need to go that far (it suggests applying functions to values in scope, which definitely makes the problem more complex), but even something basic like providing singletons / constructors would be immensely helpful.

Search terms

completions, type-aware, contextual, typed holes

@tgodzik
Copy link
Contributor

tgodzik commented Dec 9, 2022

Cool idea! We should be able to do that since we already do a similar thing in case of named completions.

@jkciesluk jkciesluk self-assigned this Jan 12, 2023
@jkciesluk jkciesluk removed their assignment Aug 24, 2023
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

No branches or pull requests

3 participants