julia-vscode / LanguageServer.jl

An implementation of the Microsoft Language Server Protocol for the Julia language.
Other
369 stars 81 forks source link

Hope to provide more powerful autocompletion about fields of struct #443

Open shilu1984 opened 5 years ago

shilu1984 commented 5 years ago

In the testfunc function, julia-vscode can normally provide the fields autocompletion of the variables eg and gp3, but it can not provide the fields completion of the others gp1 and gp2.

I understand that if fields completion is provided, the type of variable must be inferred automatically, which may require a lot of work to be done. However, the fields autocompletion of gp2 whose type is specified explicitly should be as normal as function parameter eg or local variable gp3 .

Thanks very much for your great works.

mutable struct SlipGaussPoint
    x::Float64
    y::Float64
end

mutable struct SlipEdge
    gausspoints::Vector{SlipGaussPoint}
end

function testfunc(eg::SlipEdge)
    gp1 = eg.gausspoints[2]
    gp2::SlipGaussPoint = eg.gausspoints[1]
    gp3 = SlipGaussPoint(1.0, 2.0)
    return nothing
end
Seelengrab commented 3 years ago

I think a problem similar (identical?) to this came up on zulip today:

This successfully shows completion:

While this breaks:

Is there a concrete place I could begin hacking on this/what is causing this? I've run into this & similar issues often and I'm close to the point of trying to fix it just to have peace of mind.