Skip to content

[Question/Request] Can I recycle common params for differing functions without mass copy+paste? #1772

Open
@BribeFromTheHive

Description

@BribeFromTheHive

I would like to be able to recycle a list of parameters (and types), sometimes with an extra parameter or a different set of return values. I only know how to do this via copy+paste of parameters from one function to the next, and edit as needed. However, I am trying to reduce the code volume, clarity, as well as make it easier to enact changes that should cascade to any function which uses those sets of parameters.

Here's an example:

---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
function foo(blah, barf, puke, thanks)
end

---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
---@return boolean
function bar(blah, barf, puke, thanks)
    return true
end

I'd like to be able to define a 'defined parameter set' which would allow me to do something like this:

---@parameters hmmm
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table

---@uses parameters hmmm
function foo(blah, barf, puke, thanks)
end

---@uses parameters hmmm
---@return boolean
function bar(blah, barf, puke, thanks)
    return true
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions