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

Give autocomplete suggestions for programmatic structural types #238

Open
markehammons opened this issue Nov 1, 2021 · 7 comments
Open

Comments

@markehammons
Copy link

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

class Structural(map: Map[String, Any]) extends Selectable:
  def selectDynamic(name: String) = map(name)

type Person = Structural{ val: name; val age: Int }

val p = new Structural(Map("name" -> "jacob", "age" -> 5)).asInstanceOf[Person]

p.name //I should see name + age in autocomplete

Describe the solution you'd like

Provide refinement values/definitions in autocomplete options

Describe alternatives you've considered

Going without autocomplete is the alternative

Additional contex

No response

Search terms

programmatic structural types autocomplete

@tgodzik
Copy link
Contributor

tgodzik commented Nov 2, 2021

Thanks for reporting! This already works in Scala 2, we should remember to add it to Scala 3 support.

@tambonbon
Copy link

tambonbon commented Dec 22, 2021

In mtag/scala2 there are Keyword and Keywords that suggest autocompletion.. Might be a good starting point for Scala 3 support?

@olafurpg
Copy link
Member

Is this an mtags issue or something that needs to be fixed in Scala 3? Mtags doesn’t do anything custom for structural types iirc.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 23, 2021

Is this an mtags issue or something that needs to be fixed in Scala 3? Mtags doesn’t do anything custom for structural types iirc.

I haven't been able to check that exactly, this might well be fixable in the compiler.

@kitlangton
Copy link

This would be amazing :) If this existed, generating Selectable types at compile-time could be a decent replacement for annotation macros.

@olafurpg
Copy link
Member

olafurpg commented Apr 6, 2022

Completions work like this with structural types in Scala 2. I’m not 100% familiar with how Metals uses the Scala 3 compiler but this sounds like a feature that is missing from the compiler, not Metals.

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

No branches or pull requests

5 participants