Closed Mng12345 closed 1 year ago
This is about resolving type aliases. When resolving type aliases, we stop at t
specifically because we interpret that as an intention that t
is the main type of a module.
For types that aren't aliases, you'll get completions from the full module.
So, if a type t
alias some type m
, then the auto-completion of a variable a
(assume it's type is annotated with m
) should be considered the same as type t
. This form of auto-completion is usable in other languages like Scala (this is called implicit class, i think we can make the same effect in ide). I think this is very useful, you can just define a type m
, and alias it in two or three and more different module if the business need, then you can get the auto-completions of all the function of different modules. This feature would be very cool!
Another point i think is also very useful is auto completion of aliased module, if a type t
is defined in module LongPath.M
, and you aliased the module LongPath.M
in current scope with module M
, the auto-completion of variable a
with type LongPath.M.t
should be replaced by module M
not LongPath.M
. The module System of ReScript and OCaml is very flexible, may be the ide editor limited it's power as the Short aliased module would not trigger auto completion for now.
I think aliased record types should expand as well, except if they are private. Currently, I copy a lot of type definitions over to have autocomplete. This does not feel right.
Can you write a few examples of what that means and what the trade offs would be?
I created a failing test here: https://github.com/rescript-lang/rescript-vscode/pull/834 The weird thing is, it should work according to https://github.com/rescript-lang/rescript-vscode/issues/557, but doesn't
Sorry but I still don't understand the problem. That failing test is for a hover, but here you're talking about autocomplete. And this issue is about pipe autocompletion specifically. Could you clarify exactly what the problem(s) are and how they relate to this issue (pipe completion)?
@zth Hi, i think @fhammerschmidt means that when we define a type a
which is aliased to a type t, t is defined in a module, the pipe completion of variables with type t are worked, but not worked with type a.
Sorry for hijacking this issue, and for using hover and autocomplete synonymous. I tested autocomplete and it works for aliased records (I thought it does not), but not hover.
Wow! This is worked now!!!
See the gif screen-shot below: The example code is here:
envrionment info: rescript v10.1.2 rescript-vscode v1.18.0 I have debugged the analysis, the auto completion for
m->
walked into this switch, the variable pathRev is an empty list, is auto completion for normal type (not type t of a module) not considered for now?