d-language-server / dls

A Language Server implementation for D
http://dls.dub.pm
106 stars 14 forks source link

Go to definition with UFCS #59

Open adam-r-kowalski opened 5 years ago

adam-r-kowalski commented 5 years ago

The DLS go to definition works fine if a function is being called with the conventional syntax

foo(a, b, c)

However fails if I use the universal function call syntax

a.foo(b, c)

Furthermore, if there is a templated function it (an example from the D programming language)

T[] find(T, E)(T[] haystack, E needle)
    if (is(typeof(haystack[0] != needle) == bool)) {
 ...
}

T1[] find(T1, T2)(T1[] longer, T2[] shorter)
    if (is(typeof(longer[0 .. 1] == shorter) == bool)) {

 ...
}

unittest {
  double[] d1 = [6.0, 1.5, 2.4, 3];
  float[] d2 = [1.5, 2.4];
  find(d, d2);           // <- invoke go to definition here
}

Going to definition shows both versions of find and you must choose between them, but I feel like it should do the same specialization matching the compiler does and go to the second definition.

LaurentTreguier commented 5 years ago

The first issue is a DCD issue (https://github.com/dlang-community/DCD/issues/13). The second is also somewhat a DCD issue (https://github.com/dlang-community/DCD/issues/397), I've simply made up some more code to find multiple definitions instead of only the first one, but it would need a lot more in-depth code analysis to actually find out which definition is the good one.