scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.04k stars 318 forks source link

Show aliased type for singleton completions #6540

Open nguyenyou opened 1 week ago

nguyenyou commented 1 week ago

Follow up https://github.com/scalameta/metals/pull/6498

I create this issue to list all the improvements about value completions for union types.

Named args

image

Expectation: support value completions

Pattern matching

image

Expectation: support value completions

Map

image

Expectation: support value completions

List

image

Expectation: I think just show the value for each suggestion item is enough.

cc @kasiaMarek @tgodzik

kasiaMarek commented 6 days ago

Expectation: I think just show the value for each suggestion item is enough.

This part is up for discussion, normally we add the type and it would be an odd inconsistency not to add it. I think the actual problem is that, because of the way that type is extracted, we get it in a dealised form here.

nguyenyou commented 6 days ago

HI @kasiaMarek,

I think it makes sense to keep things consistent. Can you change it to show the type name? Like we already have here:

Screenshot 2024-06-26 at 18 59 09

If it's somehow a problem that can't be addressed at the moment, then I'm ok to live with it 😄

kasiaMarek commented 6 days ago

Can you change it to show the type name?

That would be the desirable way to show it. The problem is that I'm extracting the "expected" type from the typed tree, and in the list case it is present in the tree already dealised by the compiler. I'd have to somehow alias it back - probably doable by looking at types in the scope, or come up with a better way to deal with this. Not sure how to do it properly yet.

nguyenyou commented 6 days ago

Please help to decide this 😄 I think this is just a nice to have improvement.