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

No completion when mixing auto with symbols that references types bellow the cursor #717

Open ryuukk opened 1 year ago

ryuukk commented 1 year ago

I found a weird issue, it happens with ~master

struct A
{
    B b;

    void test()
    {
        auto here = b.inside_b;
        here.|<----- cursor here
    }
}

struct B
{
    int inside_b;
}

dcd-server doesn't show anything

If i move B and put it above A, then i get completion

I came accross something similar in my Template PR, so i added a test and this change fixes it:

https://github.com/dlang-community/DCD/pull/714/commits/e7a83be721356da02f6de23dd2d4f46401f27560#diff-86f3b1d98d85f9defb3b2ad13eed3ba76c75dbbee18dc6d8ae5214a3b9b07a0dR98-R113

Test: https://github.com/dlang-community/DCD/pull/714/commits/e7a83be721356da02f6de23dd2d4f46401f27560#diff-c272767d1a40f2efc3f5daa8238fb6c8063e8220a862e86aa55432ab7cd0392dR26-R28

But no luck for this one here, since B is on a different scope

ryuukk commented 1 year ago

As a fix, we could do like for the thirdPass, and take into account the whole lookup.breadcrumbs (the whole chain) instead of a just the 1st one

Also it needs to be added from resolveTypeFromInitializer from secondPass

ryuukk commented 1 year ago

Found a fix!

Simply call secondPass a second time after thirdPass, so it takes care of everything!

I'll create a test with this code and send a PR