dlang-community / DCD

The D Completion Daemon is an auto-complete program for the D programming language
GNU General Public License v3.0
349 stars 71 forks source link

Ufcs function completion #687

Closed vushu closed 2 years ago

vushu commented 2 years ago

I have added some UFCS function chaining. meaning you can get UFCS completion for functions based on it's return type. This only works for for concrete types: struct, classes, int, bool, long, float, etc, but not for string type since DSymbol doesn't store string which i find peculiar, but it needs some investigation.

@nordlow do you mind looking at it when you have time? Thanks

@WebFreak001 do you also mind looking at it and elaborate what you meant earlier thanks. :)

vushu commented 2 years ago

It isn't trivial to add this feature and I think I need more time to make sure things are working properly, @WebFreak001 thanks for the feedback, should I maybe close this PR and maybe create a PR later on?

nordlow commented 2 years ago

Thank you so much for improving DCD!

nordlow commented 2 years ago

but not for string type since DSymbol doesn't store string which i find peculiar, but it needs some investigation.

Could the reason rather be that D's pre-defined string-types are defined in druntime's object.d as

alias string = immutable(char)[];
alias wstring = immutable(wchar)[];
alias dstring = immutable(dchar)[];

meaning we only need to support arrays in order to make D strings work?

vushu commented 2 years ago

@nordlow you welcome! I see UFCS is a feature people request for 9 years ago, so it's taken long time, before we got a little bit of UFCS completion into DCD.

I hope we will reach a point where we fully support completion for UFCS.

About object.d, I don't know, could be, but I will investigate it.

nordlow commented 2 years ago

Otherwise, LGTM.

ryuukk commented 2 years ago

Wow that's pretty impressive, thanks for your work

I tested it, so far it works very nicely, except for generics, but that's to be expected for now

ryuukk commented 2 years ago

One issue:

image

Label detail information is lost

Function should be displayed this way image (serve-d)

Same thing for when inside the parameters, i'll try to investigate on serve-d side

vushu commented 2 years ago

@ryuukk thanks! Yeah It still needs a lot of work :), I probably need to fix the labels, before going to do function chaining.

nordlow commented 2 years ago

Why the closing?

vushu commented 2 years ago

I closed it, since there are things I realized was missing and it proably needs more work.