lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Function assigned to field should be completed as function

Open carsakiller opened this issue 3 years ago • 1 comments

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Completion

Expected Behaviour

When providing an alias for a function in a table, the alias should be treated as a function.

Actual Behaviour

When providing an alias for a function in a table, the alias is treated as a field and does not get completed as a function. Hover shows that the field is a function, but completion does not agree or complete with parentheses.

image

Reproduction steps

  1. Use the below code
---@class myTable
local t = {}

---Does a thing
---@param a integer
---@param b string
---@param c boolean
function t.myFunc(a, b, c) end
t.myAlias = t.myFunc

  1. Try to get completions for the function t.myAlias

Additional Notes

This would be incredibly useful for aliasing a function — something that luassert does a lot.

Log File

No response

carsakiller avatar Sep 20 '22 14:09 carsakiller

Might be related to https://github.com/sumneko/lua-language-server/issues/1533

carsakiller avatar Sep 20 '22 14:09 carsakiller

Current implementation:

local t = {}

t.f = function () end
t.f = function (x) end
t.f = function (x, y) end

t.f --> Shows 3 items `f()`, `f(x)` and `f(x, y)` here, based on 3 `setfield`

t.g = t.f

t.g --> Only have 1 `setfield`, I can not expand it into 3 items

Need to refactor.

sumneko avatar Nov 23 '22 08:11 sumneko